Commit Graph

305 Commits

Author SHA1 Message Date
Hynek Schlawack e8f552c6f0 invert 2021-12-24 12:40:19 +01:00
Hynek Schlawack cb6627d5f8
Update comparisons to dataclasses (#872)
* Start on why

* Mention graduality

* Better commas

* Add pydantic

* Paragraphs

* Re-order why topics

* typos

* Address comments from @Julian

Co-authored-by: Julian Berman <Julian@GrayVines.com>

* link features we talk about

* Split cumbersome sentence

* give example

Co-authored-by: Julian Berman <Julian@GrayVines.com>
2021-12-24 07:38:35 +01:00
Tin Tvrtković bd0d0cc9fe
Modernize docs some more (#885)
* Modernize docs some more

* Fix doctest

* Tweak docs

* Update docs/examples.rst

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2021-12-15 13:57:16 +01:00
Hynek Schlawack 679e4b443d
NG: convert on setattr by default (#886)
* NG: convert on setattr by default

Not doing that from the get-go was an oversight.

Fixes #835

* Add optimization for default on_setattr w/ no work to do

Otherwise we'd end up with an explicit setattr every time.

* Fix optimization for NG default & j/ convert

* NG is actually 3.6+

* Add test for convert optimization for good measure
2021-12-14 15:50:37 +01:00
Hynek Schlawack dfa725bdfc Link to pyright's list of incompatibilities 2021-12-08 07:10:11 +01:00
Hynek Schlawack 659b59c64f Link David's blog post 2021-12-04 08:31:34 +01:00
Hynek Schlawack 34c55613d2
Document the common question of derived attributes (#874) 2021-11-29 09:23:45 +01:00
Hynek Schlawack 38b299d4a4 Use importlib.metadata to find the version in Sphinx docs 2021-11-28 15:04:39 +01:00
Hynek Schlawack 0b95a0c76c
Fold backward-compatibility into changelog
Signed-off-by: Hynek Schlawack <hs@ox.cx>
2021-11-25 17:06:12 +01:00
Hynek Schlawack 16cf4c50a0
GitHub really wants us to use Markdown
Signed-off-by: Hynek Schlawack <hs@ox.cx>
2021-11-25 09:31:17 +01:00
Hynek Schlawack 6954086207
Switch to markdown version of CoC so GitHub finds it
Signed-off-by: Hynek Schlawack <hs@ox.cx>
2021-11-24 09:57:32 +01:00
Hynek Schlawack 29447f81af
Document the various core names and why they exist (#871)
* Document the various core names and why they exist

Signed-off-by: Hynek Schlawack <hs@ox.cx>

* Remove stray backtick

* Add example of new API

* Link PEP 526

* future is now

* phrase and typos

* typo/grammar

* typo

* Better phrasing

* Add missing and

* less words = better

* polish

* phrasing

* looks weird but is correct

* comma spliiiiceeeee

* example

* make it sound less dry

* fix

* phrasing
2021-11-24 09:39:41 +01:00
Hynek Schlawack 6e04e869e6 Fix links 2021-11-23 13:56:38 +01:00
Tin Tvrtković d7d9c5dde7
Switch to NG APIs in docs (#863)
* Switch to NG APIs in docs

* Review feedback

* Convert examples.rst

* Tweak doctest

* Doctest fixes

* Tweak some more

* Fix

* Update docs/init.rst

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

* Fix doctest

* Fix README

* Update docs/examples.rst

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

* Review feedback

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

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

* Fix link

Co-authored-by: Hynek Schlawack <hs@ox.cx>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-11-22 07:35:36 +01:00
Stefan Scherfke c6143d518b
Add "no_run_validators()" context manager (#859)
* Add "no_run_validators()" context manager

* Move functions to validators module

* Update changelog entry

* Add a few docstring improvements and fixes

* Update tests/test_validators.py

* Minor polish

Signed-off-by: Hynek Schlawack <hs@ox.cx>

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2021-11-17 07:05:01 +01:00
Hynek Schlawack c4587c0793 Add missing author metadata 2021-11-15 10:08:16 +01:00
Hynek Schlawack a76f750d77 We build docs only on Python 3 2021-11-15 09:59:21 +01:00
Hynek Schlawack 031ba36048 Add epub metadata 2021-11-15 09:58:33 +01:00
Hynek Schlawack 8592ea6aa5 Stack Overflow is two words 2021-10-28 07:11:16 +02:00
Hynek Schlawack 84eb79905f Fix Python 2/2020 tense 2021-10-28 07:06:57 +02:00
Hynek Schlawack 95b70bde2e Clarify that validators/converters only run on init 2021-10-28 07:00:01 +02:00
Kyle Altendorf 2eb5d97ef3
create a :mod:`attr` and :mod:`attrs` for intersphinx links to the package itself (#850)
* Try to create a :mod:`attr` and :mod:`attrs`

https://github.com/python-attrs/attrs/issues/849

* Update index.rst

* Update index.rst

* Update index.rst
2021-10-12 14:55:26 +02:00
Kyle Altendorf 68be706621
Avoid attr.attr.frozen and attr.attr.mutable in Sphinx object inventory (#851)
https://github.com/altendky/qtrio/issues/269
2021-10-12 07:42:46 +02:00
Hynek Schlawack 124c20cde0
Document Attribute.eq_key & .order_key (#847)
* Document Attribute.eq_key & .order_key

Fixes #839

Signed-off-by: Hynek Schlawack <hs@ox.cx>

* Add for example
2021-10-06 12:21:36 +02:00
Stefan Scherfke 52fcad29bb
Add additonal validators (#845)
* Add additonal validators

* Python 2 \o/

* Add changelog entry

* Add "versionadded" tags

* More python 2

* Add doctests and rename maxlen to max_len

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2021-09-24 12:47:19 +02:00
Rebecca Turner e84b57ea68
Inline distutils.util.strtobool in tests (closes #813) (#830)
* Inline distutils.util.strtobool in tests (#813)

`distutils` is deprecated in Python 3.10 and slated for removal in
Python 3.12. Fortunately, `attrs` only uses `distutils` once and it's
trivial to remove.

As suggested by @sscherfke, add the `to_bool` converter to
`converters.py`.

Closes #813

Co-authored-by: Stefan Scherfke <stefan@sofa-rockers.org>

* Use :raises: directive in docstring

* Remove f-strings for Py2.7 and 3.5 support

* Add to_bool tests

Co-authored-by: Stefan Scherfke <stefan@sofa-rockers.org>
Co-authored-by: Hynek Schlawack <hs@ox.cx>
2021-08-10 07:45:28 +02:00
Karthikeyan Singaravelan 8613af97bb
Add __match_args__ to support match case destructuring in Python 3.10 (#815)
* Add support to generate __match_args__ for Python 3.10.

* Add versionadded directive.

* Update stubs.

* Update changelog and add a test to typing examples.

* Fix error regarding new-style classes in Python 2.

* Fix lint error regarding line length.

* Fix lint error regarding trailing whitespace.

* Add docstrings for interrogate.

* Use _has_own_attribute instead of cls.__dict__ contains check.

* Update docs as per review comments.

* Revert mistaken changelog update.

* Add Python 3.10 pattern matching syntax test cases.

* Update define signature with match_args.

* Fix conftest formatting.

* Fix isort formatting.

* Bump to Python 3.10 to parse syntax.

* Bump basepython of lint to Python 3.10 for parsing.

* Move lint to py310

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2021-05-18 07:02:06 +02:00
Hynek Schlawack f10d050864
Revert recursive evolve (#806)
* Revert "Recursively evolve nested attrs classes (#759)"

* Add regression test

* lol legacy python

* Add newsfragment

* Add a test to prevent inst -> dict replacement breaking
2021-05-06 15:26:27 +02:00
Hynek Schlawack f41db43541 Unpin pyright & minor docs polish
ref #796
2021-05-05 16:06:09 +02:00
Alex Ford 7e372c56a2
Implement pyright support via dataclass_transforms (#796)
* Add __dataclass_transform__ decorator.

* Add doc notes for pyright dataclass_transform support.

* Fix docs build error.

* Expand docs on dataclass_transform

* Add changelog

* Fix docs build

* Fix lint

* Add note on __dataclass_transform__ in .pyi

* Add baseline test of pyright support via tox

* Add pyright tests to tox run configuration

* Fix test errors, enable in tox.

* Fixup lint

* Move pyright to py39

* Add test docstring.

* Fixup docs.

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2021-05-05 10:24:53 +02:00
Hynek Schlawack fc0d60e370 Simplify import 2021-05-05 10:15:26 +02:00
Hynek Schlawack 743f973889
Add narrative docs for #787 (#801) 2021-05-04 17:41:14 +02:00
0xflotus f96494f462
fix: small error in docs (#794) 2021-04-23 18:04:35 +02:00
Hynek Schlawack f47e568c9e
Make NG APIs official (#786) 2021-04-09 20:36:10 +02:00
Hynek Schlawack 066d1ca7df Add narrative docs for #731
Signed-off-by: Hynek Schlawack <hs@ox.cx>
2021-04-06 07:27:11 +02:00
Thomas Grainger 0a6f8075eb
add sphinx-notfound-page (#777)
Co-authored-by: Hynek Schlawack <hs@ox.cx>
2021-03-10 07:57:26 +01:00
Hynek Schlawack ded92256e2 Small addendums to #773 2021-02-28 13:39:34 +01:00
Antonio Botelho f580185cc4
Undeprecate cmp (#773)
* Document comparison

* Grammar

* Stress independence of eq/order

* Add example for eq

* Be consistent with fields

* Undeprecated cmp

* Update doc to remove cmp deprecation

* Reintroduced deprecation warning on Attribute cmp property

* Added changelog file

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2021-02-28 13:20:40 +01:00
Hynek Schlawack 58d2adce57
Document comparison (#768)
* Document comparison

* Grammar

* Stress independence of eq/order

* Add example for eq

* Be consistent with fields

* Update docs/comparison.rst

Co-authored-by: Julian Berman <Julian@GrayVines.com>

* Update docs/comparison.rst

Co-authored-by: Julian Berman <Julian@GrayVines.com>

* Update docs/comparison.rst

Co-authored-by: Julian Berman <Julian@GrayVines.com>

* Clarify

Co-authored-by: Julian Berman <Julian@GrayVines.com>
2021-02-26 07:53:57 +01:00
Hynek Schlawack 1e1742a9c5 Anarchy! 2021-02-25 08:46:28 +01:00
Kyle Barron 1b27630d8a
Fix typo (#765) 2021-02-25 07:25:18 +01:00
Antonio Botelho aefdb117fa
Allow user to customize how an attribute is compared (#435) (#627)
* Updated implementation of comparison behaviour customization.

* Fixed version of next release, updates newsfragment and documentation.

* Fixed documentation.

* Fixed documentation.

* Fixed comments and changelog.

* Fix doctest error

* Update src/attr/_make.py

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

* Pass eq_key and order_key explicitly in _CountingAttr

* Merged with master and resolved conflics after introduction of _make_method

Co-authored-by: Antonio Botelho <antonio@inhames.com>
Co-authored-by: Hynek Schlawack <hs@ox.cx>
2021-02-22 08:48:34 +01:00
Stefan Scherfke fe6eb31200
Recursively evolve nested attrs classes (#759)
* Recursively evolve nested attrs classes

Fixes: #634

* Apply suggestions from code review

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

* Update tests for recursive evolve()

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2021-02-19 07:01:09 +01:00
Hynek Schlawack 446386a36d Don't set pygments style
c.f. https://github.com/pradyunsg/furo/issues/68#issuecomment-752606308
2020-12-31 10:45:33 +01:00
Nicholas Coltharp e09b1d6423
Infer type annotations from converters (#710)
* Infer annotations from converters

* Use semantic newlines

* Add 787.change.rst

* Don't let type annotations override converters

* Make pipe() infer type annotations

* Use PY2 instead of sys.versioninfo >= (3, 3)

* Avert crashing with a nullary converter

* Small doc change

* Add type inference for optional()

* Make pipe() annotations actually work

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2020-12-13 16:30:06 +01:00
Tobias Bieniek c5eb24ef0b
logo: Split `path` into multiple paths (#719)
Passing SVG files through `svgo` often makes them harder to edit for applications like InkScape or Sketch. This commit splits the single `path` in the files into multiple paths to resolve this issue. The file is now slightly larger, but should be a lot more maintainable. If more compression is needed then svgo should be applied in a build step, but the repository should contain the raw source file.
2020-11-20 08:36:07 +01:00
Hynek Schlawack 32fb12789e Add white logo for dark mode
Run both through svgo (saved 17.2% for white and 23% for black).
2020-11-16 07:52:35 +01:00
Hynek Schlawack 3d66e5727b Exclude GitHub issues from linkcheck to avoid rate limits 2020-11-05 10:51:23 +01:00
Alex Chan cd2f886d63
Use 'i' and 'k' to better distinguish variables in an example (#713) 2020-11-04 11:52:42 +01:00
Andrei Bodrov bc527b9f29
[RFC] kw_only python 2 backport (#700)
* Added kw_only support for py2

* Docs update

* Added changelog

* Better exception message, moved code to function

* Moved py2-only functions under if PY2:

* Tested fancy error message for unexpected kw-only argument

* Tested fancy error message for unexpected kw-only argument

* Fixed line length

* Added versionchanged

* Updated docs

* Moved functions back under if PY2 - seems codecov doesn't like them in module scope

* Blacked

* Fixed changelog.d

* Removed redundant brackets in test

* Added assertion to the _unpack_kw_only_lines_py2 - hope it will increase code coverage

* List comprehension -> for loop

* lines.extend? I do not like for-loops

* Fix code

* Fixed style/added comment

* Fixed docs (removed python2 mention)

* Fix lint

* Better docstring

* Rewritten docstring and added example code

* Added quotes

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2020-10-19 11:00:00 +02:00