Commit Graph

451 Commits

Author SHA1 Message Date
Hynek Schlawack d82c3f361a
docs 2024-07-31 10:58:09 +02:00
Hynek Schlawack bcda3e17ba
docs: don't assume people use pip anymore 2024-07-31 09:39:28 +02:00
Hynek Schlawack f5683b852b
converters: allow wrapping and passing self and fields (#1267)
* converters: allow wrapping & takes_self

* Add takes field

* Add news fragment

* Refactor name and call creation

* Make argument names more idiomatic

* Add missing hints

* Make 3-arg converters zero-overhead at runtime

* Remove unnecessary changes

* More idiomatic name

* Explain method

* Make pickle test more meaningful

* Add unit tests for fmt_converter_call

* Check our eq works too

* Convert Converter docstring to Napoleon

* Fix rebase fubar

* Add ~types~

* Comment out failing mypy tests for now

* Fix mypy tests

* Add warning

* Add narrative docs

* Fix converter overloads, add tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Tin Tvrtković <tinchester@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-28 13:55:24 +00:00
Hynek Schlawack 01d35a3795
docs: fix typo 2024-07-22 05:49:19 +02:00
Hynek Schlawack 8a8cd91bdf
Switch docstrings to Napoleon style (#1308)
* Switch docstrings to Napoleon style

This makes them much more readable while editing.

c.f. https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html

* Add example for Raises
2024-07-21 12:06:19 +02:00
Tin Tvrtković a8808a2b3e
Speed up __eq__ (#1310)
* Speed up __eq__

* Changelog, disallow nans in tests

* Fix `eq_key` comparisons

* Rework changlelog

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Make docs more precise

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-21 09:53:35 +00:00
Hynek Schlawack 88e13dd6ab
Make logos slightly smaller so 4 fit in 1 line
Like on GitHub
2024-07-19 11:24:36 +02:00
Hynek Schlawack 6733796c5f
Add nuance to subclassing statements
C.f.
https://stackoverflow.com/questions/78424953/how-to-implement-class-composition/78427868?noredirect=1#comment138293629_78427868
2024-07-19 11:11:48 +02:00
Hynek Schlawack 52893141db
Use relative sponsor links in docs 2024-07-19 11:09:25 +02:00
Hynek Schlawack 3df6017637
Improve sponsor handling (#1304)
* Improve sponsor handling

* Try to use tox

* Use python instead of pip

* Be consistent
2024-07-17 13:27:30 +00:00
Hynek Schlawack 829c2ff15a
docs: improve RTD 2024-07-17 14:14:35 +02:00
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
Hynek Schlawack 37ac3ef088
docs: improve why 2024-07-15 16:16:19 +02:00
Hynek Schlawack a518d9ddfe
docs: make more examplar 2024-07-15 11:27:08 +02:00
Hynek Schlawack 8e759ce878
docs: better separation of the ToC 2024-07-15 11:26:45 +02:00
Hynek Schlawack 08b1b9ccd0
docs: add more terms that ppl might know 2024-07-15 11:00:55 +02:00
Hynek Schlawack 6f99945f40
Actual white 2024-05-26 21:00:49 +02:00
Hynek Schlawack e976ebcac8
Fix ratio 2024-05-26 20:56:27 +02:00
Hynek Schlawack bccbcad65d
Leave some breathing room 2024-05-26 20:42:38 +02:00
Hynek Schlawack 1a7b87daae
Add white background 2024-05-26 20:33:24 +02:00
Hynek Schlawack 7649f6e6b5
sponsors: add Klaviyo 2024-05-25 08:23:46 -04:00
pre-commit-ci[bot] f708291c4f
[pre-commit.ci] pre-commit autoupdate (#1281)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 24.4.0 → 24.4.2](https://github.com/psf/black/compare/24.4.0...24.4.2)
- [github.com/astral-sh/ruff-pre-commit: v0.4.1 → v0.4.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.1...v0.4.3)

* Fix Sphinx warning

* pytest-mypy-plugins doesn't work on 3.13 yet

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Hynek Schlawack <hs@ox.cx>
2024-05-08 08:19:47 +00:00
my1e5 f7f317ae4c
Fix small typo in init.md (#1277)
Co-authored-by: Hynek Schlawack <hs@ox.cx>
2024-04-24 14:39:04 +00:00
Hynek Schlawack a1053048f1
Fix typo 2024-03-18 15:34:38 +01:00
Hynek Schlawack 9e803dd683
to_bool: avoid creating sets on each call 2024-03-17 09:04:54 +01:00
Hynek Schlawack 9cf3d338f4
Improve/harmonize docstrings 2024-03-17 08:07:39 +01:00
Hynek Schlawack 8460190b29
Remove attrs.validators.provides (#1265)
* Remove attrs.validators.provides

* Add news fragment
2024-03-16 21:15:47 +00:00
Hynek Schlawack f590f44cfd
docs: style improvements 2024-03-16 16:22:58 +01:00
Hynek Schlawack c306e2eaae
docs: stress design 2024-03-16 15:28:17 +01:00
Hynek Schlawack 9c1f649983
docs: re-shuffle intro 2024-03-16 15:19:17 +01:00
koenigdavidmj 9143f126c5
Fix broken link from attr API reference back to attrs (#1260)
`attr.fields_dict` was a link back to itself. The intention, like all the other nearby aliases, was to refer back to the version in `attrs` for the full story.
2024-03-14 16:35:23 +00:00
Carlton Gibson 1cb58a5536
Fixed make_class example. (#1258)
The example only makes sense if `C2` is the class examined, as that's the one we dynamically created.
2024-03-12 18:12:43 +00:00
mikejturner 69b6626046
Modifies sentence and provides link to explanation of mutable defaults gotcha in the documentation (#1251)
Adds link to explanation of mutable default gotcha
2024-02-29 06:24:29 +00:00
Hynek Schlawack ec9ef8d174
docs: add super warning 2024-02-22 05:55:45 +01:00
Hynek Schlawack 3e868366ad
Update index.md 2024-01-15 18:52:56 +01:00
Hynek Schlawack deb0133f63
docs: compound adjective 2024-01-13 07:26:19 +01:00
richardsheridan f070a21a3e
correct reference in Setters section of api.rst (#1224) 2024-01-12 08:38:07 +00:00
Hynek Schlawack 2bddbdb704
Add codespell 2024-01-08 07:37:20 +01:00
Tim D. Smith b5e936df55
Point to data class transform PEP (#1223)
PEP 689 is the unstable C API tier; PEP 681 is data class transforms.
2024-01-05 09:03:24 +00:00
Hynek Schlawack cee6192bd1
No periods in headings 2023-12-31 12:12:51 +01:00
Hynek Schlawack bfd70c9eeb
docs: make it a link 2023-12-31 11:36:01 +01:00
Hynek Schlawack bfbea3a901
docs: wordsmith 2023-12-31 11:34:25 +01:00
Hynek Schlawack 41df262f2d
Fix links 2023-12-31 07:19:11 +01:00
Hynek Schlawack 5688711bd8
Add social card 2023-12-31 07:04:02 +01:00
Hynek Schlawack c2ff96f554
Move sponsor logo hosting to docs
So we don't have to keep expired sponsors in the repo forever.
2023-12-30 11:55:50 +01:00
Brian Pugh 5aea24125a
Move conditional clause to beginning for validator/converter docs. (#1213)
Move conditional clause to beginning for validator/converter docs. Provide converter example.

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2023-12-29 15:48:42 +00:00
Hynek Schlawack 4c2b9e31bc
docs: add two warning about no-types mode
Fixes #1161
2023-12-29 16:30:21 +01:00
Hynek Schlawack 363ccf4821
docs: clean up index 2023-12-29 16:12:11 +01:00
Hynek Schlawack 84274fdecc
docs: add another slots caveat
Fixes #1211
2023-12-29 16:02:55 +01:00
diabolo-dan 597c3a8adb
Add support for cached_properties to slotted attrs classes. (#1200)
* Add support for cached_properties to slotted attrs classes.

* Remove locking from implementation

* Add test for multiple cached properties and fix bug

* Add changelog file

* Document slotted cached properties

* Add cached_property hypothesis check.

* Only run cached_property imports on python 3.8+

* Use cached _obj_setattr instead of `object.__setattr__`

* Correctly resolve mro for __getattr__ in cached properties

* Use _get_annotations rather than branching on class dict entry

* Optimise __getattr__ code by front loading branching, and injecting locasl variables

* Remove unnecessary `__attrs_original_getattr__` from class dictionary.

---------

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2023-12-08 18:24:25 +00:00