attrs/docs
Libor Martínek 7c9b31ea7b
Add `attrs.validators.or_` validator (#1303)
* Implement attrs.validators.or_ validator

* Add tests/test_validators.py::TestOr test cases

* Add test for _OrValidator.__repr__ method

* Add description of attrs.validators.or_ to docs/api.rst

* Add changelog entry

* Swap double quotes for single because doctests don't like it

* Rename changelog fragment pointing to incorrect number

* Silence ruff linter warnings

Although good warning in general, in this particular code, they
do not fit here.

* BLE001 Do not catch blind exception: `Exception`
    `validators` usually raise `ValueError` upon their violation.
    However, it's not the only `Exception` they can raise - cf.
    `attrs.validators.not_` - therefore, it is desirable to catch
    them all!
* PERF203 `try`-`except` within a loop incurs performance overhead
    Fair point, but the loop is written in a way to short-circuit,
    ie. it will finish when a first validator is satisfied.
* S112 `try`-`except`-`continue` detected, consider logging the exception
    Not applicable here, we care only if **all** validators raise
    an exception, which is already accomodated for after the `for`
    loop.

* Apply suggestions from code review

Co-authored-by: Hynek Schlawack <hs@ox.cx>

* Rework example of or_ validator in api/docs.rst

* Update docs/api.rst

---------

Co-authored-by: Hynek Schlawack <hs@ox.cx>
Co-authored-by: Libor <libas.martinek@protonmail.com>
2024-07-17 12:01:41 +00:00
..
_static Actual white 2024-05-26 21:00:49 +02:00
Makefile
api-attr.rst Fix broken link from attr API reference back to attrs (#1260) 2024-03-14 16:35:23 +00:00
api.rst Add `attrs.validators.or_` validator (#1303) 2024-07-17 12:01:41 +00:00
changelog.md
comparison.md docs: explain how we compare (#1192) 2023-10-18 08:14:14 +02:00
conf.py [pre-commit.ci] pre-commit autoupdate (#1281) 2024-05-08 08:19:47 +00:00
examples.md docs: style improvements 2024-03-16 16:22:58 +01:00
extending.md docs: make more examplar 2024-07-15 11:27:08 +02:00
glossary.md Fix links 2023-12-31 07:19:11 +01:00
hashing.md
how-does-it-work.md docs: style improvements 2024-03-16 16:22:58 +01:00
index.md docs: better separation of the ToC 2024-07-15 11:26:45 +02:00
init.md docs: add more terms that ppl might know 2024-07-15 11:00:55 +02:00
license.md
names.md
overview.md Fix typo 2024-03-18 15:34:38 +01:00
types.md docs: make more examplar 2024-07-15 11:27:08 +02:00
why.md docs: improve why 2024-07-15 16:16:19 +02:00