Commit Graph

464 Commits

Author SHA1 Message Date
Douglas Griffith 4580a74fc9
update frozen post-init example to use frozen (#1367) 2024-10-29 14:34:22 +00:00
esteevens 58cd3ae112
Fix tiny typo in glossary.md (#1363) 2024-10-25 06:17:00 +00:00
Hynek Schlawack a59c5d7292
docs: fix intersphinx links 2024-09-27 05:56:55 +02:00
Geoffrey Thomas 2afd663bf4
Document how to handle class variables/constants in typed syntax (#1352)
* Document how to handle class variables/constants in typed syntax

This is mentioned very briefly in the API docs for `auto_attrib` but
it's not easy to find if you don't already know about `typing.ClassVar`.

* Fix typo

* 2 empty lines before headers

---------

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2024-09-23 04:24:03 +00:00
Geoffrey Thomas a785e6b4ae
Rephrase the "Private Attributes and Aliases" section (#1351)
It took me a bit to figure out what was meant by the link to the
characteristic issue and why there is no such thing as a private
argument. Incorporate (my understanding of) the meaning inline and also
provide an example of how to work around the _1 syntax error.
2024-09-23 04:16:08 +00:00
Hynek Schlawack 5c3af47603
Actually add 2024-08-26 07:09:33 +02:00
Hynek Schlawack 9a11b57e8c
Add Polar.sh 2024-08-26 07:09:06 +02:00
Hynek Schlawack 53e632c521
Try fitting 4 logos per line on PyPI 2024-08-06 13:40:17 +02:00
Hynek Schlawack 69d6fd1c6a
Remove stale footnote 2024-08-05 17:06:48 +02:00
Hynek Schlawack dbb25ce347
Add support for __attrs_init_subclass__ (#1321)
* Add support for __attrs_init_subclass__

* Fix test docstring

* Fix import

* Add versionadded

* Invert logic and add example

* Explain behavior in API docs

* Move to narrative docs

* Link

* once is enough

* why hide

* endash

* better phrasing
2024-08-03 13:38:12 +02:00
Hynek Schlawack 42c954869d
Invert API docs to point from NG to OG (#1316)
* Add disclaimer to attr NS

* Transplant API docs from attr.s to attrs.define

* Transplant API docs from attr.ib to attrs.field

* Remove stale references to attr.ib

* Fix refs

* Link to glossary

* Explain why

* Links from API docs, too

* Link type annotations for good measure
2024-08-02 08:03:14 +02:00
Hynek Schlawack b78abadbbf
docs: add glossary entries for field & attribute 2024-08-01 06:43:24 +02:00
Hynek Schlawack a365cdc5fe
More f-strings (#1317) 2024-07-31 13:37:38 +02:00
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