Commit Graph

258 Commits

Author SHA1 Message Date
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
Hynek Schlawack ae51f34681 Attribute.assoc → evolve 2020-10-17 07:27:36 +02:00
Hynek Schlawack 9f2a7857dc Furo works with SVG!
Fixes #674
2020-10-16 08:19:09 +02:00
Stefan Scherfke 0eae613ce1
Add hooks for field transformation and for asdict serialization (#653) 2020-10-15 09:33:59 +02:00
Hynek Schlawack ffe49c8241
Switch to furo
Now everything is @pradyunsg's fault! 🎉

Signed-off-by: Hynek Schlawack <hs@ox.cx>
2020-10-05 06:35:40 +01:00
Hynek Schlawack 6aca10f2a7 Beef up glossary and urge people more to read it
Ref #691
2020-09-28 11:27:37 +01:00
Hynek Schlawack b0d2d92787 Clarify __subclasses__ behavior in slotted classes
Ref #691,#407
2020-09-28 11:16:30 +01:00
Thomas Grainger fe8fe011df
the twisted backwards compatability policy moved (#688)
in a backwards compatible way
2020-09-10 13:22:20 +02:00
Kyle Altendorf 42a3eb29d1
Doc type: into -> in (#679) 2020-08-31 09:51:43 +02:00
Hynek Schlawack d02b76de16 Fix indentation in docs 2020-08-21 12:13:12 +02:00
Hynek Schlawack 82b9e92f25
Explain slots=True and monkeypatching
ref #668

Signed-off-by: Hynek Schlawack <hs@ox.cx>
2020-08-21 08:21:23 +02:00
Hynek Schlawack fda437c91f
Add attr.field (#669)
* Add attr.field

* Add newsfragment

* better wordzzz

* Typo and clarification
2020-08-20 19:01:34 +02:00
Hynek Schlawack c67a649b38 Explain that slotted classes don't support multiple inheritance
Fixes #667

Co-authored-by: Tin Tvrtković <tinchester@gmail.com>
2020-08-19 14:37:46 +02:00
Hynek Schlawack b02335f59d
Add attr.define/mutable/frozen (#666)
* Add attr.auto/mutable/frozen

Prepare for import attrs y'all!

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

* Try combining coverage using 3.8, always

* Add tests for overriding of auto_attribs

* Clarifications

* Add newsfragment

* s/auto/define

This is going be the next-gen name anyways, so no need to introduce new names.

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

* Missed two

* Add type stubs

* Beg for patience

* Explain second setup-python action

* fix comment
2020-08-17 16:22:33 +02:00
Hynek Schlawack e2ced32c46 Rephrase for clarity 2020-07-23 14:50:04 +02:00
David Euresti 8cae2a99da
Add documentation about string annotations (#659) 2020-07-22 21:15:18 +02:00
Hynek Schlawack 3aa497d02b
Move resolve_types to _funcs and tweak docs
Signed-off-by: Hynek Schlawack <hs@ox.cx>
2020-07-22 12:19:58 +02:00
David Euresti c42bf9ebb9
Add attr.resolve_types (#302)
* Add attr.resolve_types

This adds `attr.resolve_types` which can be used to resolve forward declarations in classes created using `__annotations__`

Fixes #265

* Fix flake8 and doctest

* Missed one

* Fix lint

* Address CR comments
Add to stubs
Make it a decorator, because why not?

* Fix test

* Rerun-tests please

* Rerun-tests please

* Fix another

* Fix lint

Co-authored-by: David Euresti <david@zapgram.com>
2020-07-22 11:43:07 +02:00
Hynek Schlawack 05e930c36f
Rename converters.chain to converters.pipe
Consistent with setters.pipe and conveys better that it acts like a UNIX pipe.

Signed-off-by: Hynek Schlawack <hs@ox.cx>
2020-07-21 14:43:09 +02:00
Hynek Schlawack 2f6fd8516c
Add on_setattr hooks to attr.s and attr.ib (#660)
* Add on_setattr hooks to attr.s and attr.ib

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

* Add PR newsfragment

* Fix attr.s doc sig

* Make _DisableType private

* Mark setters.frozen as NoReturn

* Rename setters.DISABLE to setters.NO_OP to clarify its purpose

DISABLE sounds less purposeful and doesn't convey its meaning as well.

* Fix type

* Loosen up type for convert even further

* Tighten type a tiny bit
2020-07-20 12:43:10 +02:00
Hynek Schlawack 428bbcf0d3 Fix typo 2020-07-20 10:50:17 +02:00
Hynek Schlawack cab4557e5b
Document how to write aliases that are recognized by mypy (#650)
Co-authored-by: David Euresti <david@euresti.com>
2020-07-20 10:10:03 +02:00
Hynek Schlawack 277a5c1d45
Add control to generate __[sg]etstate__ (#642)
* Add control to generate __[sg]etstate__

Pass *getstate_setstate* to attr.s to control the generation.  Mostly
interesting for disabling it in slotted classes.

Fixes #512,#513

* Update glossary.rst
2020-05-11 07:11:24 +02:00
Hynek Schlawack 6fcdc3d78f Fix docs for Sphinx 3 2020-04-28 09:21:19 +02:00
Hynek Schlawack 33b61316f8
Fix attribute collection (#635)
Co-Authored-By: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
2020-04-06 11:41:52 +02:00
Hynek Schlawack 2a1e8cf4da Remove intersphinx mapping to zope.interface
One link is not worth a broken CI.
2020-03-29 14:40:25 +02:00
Hynek Schlawack 196d948613
Add auto-detection of self-implemented methods (#607)
* Implement auto_detect

Fixes #324

* Add test demonstrating total_ordering

* Ensure the order of applying total_ordering does not matter

* Warn if a method is missing

* Revert "Warn if a method is missing"

This reverts commit 590ef43458040e0a1b9f3644ba22b4229f7d6990.

* Add stern warning that nobody will read
2020-03-16 13:03:12 +01:00
Hynek Schlawack 609b10e84f Refactor docs and switch to RTD theme
Our API docs are much more readable on it.

Remove testimonials, they don't serve that much and take up space.

Slightly refactor main docs page.
2020-03-08 07:46:56 +01:00
Nativ Issac 9fcfe3479f Add and_ converter (#618)
* Add and_ converter

* update _make

* Refactored code according to review

* fixed some linting errors

* minor refactor

* fixed CR comments

* fixed CR comment #2

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2020-03-06 10:34:11 +01:00
Hynek Schlawack 44289f2548 Add missing exception to API docs 2020-01-06 12:34:58 +01:00
Kyle Altendorf 3fff9ee352 Mention attr.fields() after __attrs_attrs__ in 'How does it work' (#605)
* Mention attr.fields() after __attrs_attrs__ in 'How does it work'

The mentioning of __attrs_attrs__ in a 'how does it work' document makes sense but it seems important to mention that there are good non-dunder ways to access the data.

* Correct how-does-it-work.rst change to use semantic newlines

* it's attr not attrs...

* Simplify attr.fields link
2020-01-03 15:37:39 +01:00
Tim Gates ee44563094 Fix simple typo: developement -> development (#600)
* Fix simple typo: developement -> development

* Add towncrier file

* Fix PR number
2019-11-18 08:54:17 +01:00
Hlynur Freyr Jónsson 4a48b24988 Fix typo (#591)
one -> None
2019-10-23 05:00:04 +02:00
Hynek Schlawack eec7e43d37 Fix links 2019-10-15 07:44:05 +02:00
Hynek Schlawack 3432df5711 At least mention pytype 2019-10-14 16:44:23 +02:00
Hynek Schlawack 528323040f Prepare 19.2.0 2019-10-01 16:21:36 +02:00
Hynek Schlawack 735b3bef48 drop the ing 2019-10-01 16:00:33 +02:00
Hynek Schlawack 0614510159
Merge branch 'master' into version-info 2019-10-01 15:16:30 +02:00
Hynek Schlawack f083cd7b65 Clarify need for attr.ib for attr decorator validators
Ref #466
2019-10-01 14:38:22 +02:00
Hynek Schlawack 516fc28186 Typo 2019-09-26 06:50:04 +02:00
Hynek Schlawack bd135d43f1 Add attr.__version_info__
This allows users to check for features and avoid deprecation warnings without
breaking backward compatibility.
2019-09-26 06:50:04 +02:00
Hynek Schlawack 08fcfe91d4
Split cmp into eq and order (#574)
* Split cmp into eq and order

Fixes #170

* Fix tests on old pypy3 versions

Old as in: currently on AP.

* Fix issue number and clarify newsfragment

* Clarify behavior and interaction between cmp/eq/order

* This sounds better

* Address Julian's review comments

* Missed a cmp

* Test the behavior of Attribute.cmp

* Make test more idiomatic

* Explain assumptions

* Clarify comment

* Grammar

* One more cmp!
2019-09-22 15:07:19 +02:00
Julian Berman 8824dc26c2 Add default_role for Sphinx. (#571)
* Add default_role for Sphinx.

Fix a bunch of broken refs along the way, which become
errors now via -W if you have default_role set.

In theory you can catch those via sphinx-build -n (i.e.
nitpick mode), which IMHO is a decent idea anyhow, but it's
a longer diff to enable that because it'd involve fixing a
bunch of the places that try to reference types that don't
exist (e.g. :type foo: Any value). But obviously can be done.

Also didn't actually use this anywhere yet (the any role),
but will do so in a follow-up if this is acceptable.

* Remove the roles from builtin objects to demo any.

* Style.

* Add z.i to intersphinx.

Enables the link to z.i.Interface.

* Enable nitpick mode.

Fix the remaining broken links or whitelist them via nitpick_ignore.

* Kill all :func:s.

* Kill all :class:es.

* Kill all :doc:s.

* Kill all :ref:s.

Except one, that probably meant :func:, and which
is a duplicate ref.

* Kill :exc: and :data:.

* Kill :mod:s.

* Kill new explicit refs from the merge.
2019-09-09 15:02:16 +02:00
Kurt Rose 08b15877c7 Add matches_re validator (#552)
* matches

* added flags pass-through, and multiple function options; defaults to fullmatch

* move logic from validate to constructor

* cleaned up default args / fullmatch emulation

* fixed meta validator

* cleaned up default args / fullmatch emulation

* test cleanup

* versionadded tag

* added changelog entry

* cleaned up type checks, added to api docs and pyi type signature

* black formats

* black formatting

* 100% test coverage

* added example usage of matches_re to docs

* fixing py2 swallow type error and wrong quote in doctest

* explicit tests for all possible func args

* pragma no branch to get coverage 100%
2019-09-09 10:48:52 +02:00
wouter bolsterlee 0b913645c5 support custom repr() callable for attributes (#568)
* wip: support custom repr() callable for attributes

see #567

* extend ‘repr=...’ arg type in .pyi stubs

* expand docstring for attr.ib()

* add changelog entry

* add docs with example

* improve my copy/paste skills 🙈

* fix grammar

* fix typo in changelog entry

* fix and improve attrib() docstring

* detect custom repr() once, not per call. be strict about bool.

* use rst syntax, not markdown

* apply hynek's suggestions for changelog entry

* add ‘versionchanged’ note in docstring

* add custom attribute repr= to typing example

* simplify comment
2019-09-06 14:26:08 +02:00
Anders Huss b5e825dd19 Docs: clarify current behaviour/motivation for `slots=True` and autogeneration of __get/setstate__ (#521)
* clarify current behaviour for slots=True and autogeneration of getstate setstate

* fix glossary rst formatting

* Fix grammar docs/glossary.rst

Co-Authored-By: andhus <andhus@kth.se>
2019-07-20 12:27:09 +02:00
William Jamir Silva 68af33ec05 Improve the error message informing the value that it got it (#536)
* Improve error message of iscallable validator

* Add stubs for NotCallableError

* Add changelog for iscallable validator
2019-07-20 11:55:26 +02:00
Oliver Bestwalter 615054392a Rename remaining validator/default decorator examples with unclear names (#544)
The documentation already explains well why validator or default decorated methods
must not have the name of existing attributes (because they would be overridden).

This replaces the last remaining examples not using the explicit explanatory name.
2019-06-17 09:17:29 +02:00