* 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>
* Don't reset custom __setattr__ in slotted classes
Fixes#680
Signed-off-by: Hynek Schlawack <hs@ox.cx>
* Simplify
Signed-off-by: Hynek Schlawack <hs@ox.cx>
* Be defensive about __bases__
Signed-off-by: Hynek Schlawack <hs@ox.cx>
* _Classes_ always have a __dict__
* Tighten xfail
* Clarify what need to be reset and when
Signed-off-by: Hynek Schlawack <hs@ox.cx>
* Reset __attrs_own_setattr__ along with __setattr__
Signed-off-by: Hynek Schlawack <hs@ox.cx>
* Update src/attr/_make.py
Co-authored-by: Paul Ganssle <paul@ganssle.io>
* Differentiate between own (= attrs) and custom (= user) __setattrs__
Signed-off-by: Hynek Schlawack <hs@ox.cx>
* We've always used __bases__ in our call to type()
So no reason for being defensive.
* Update tests/test_setattr.py
Co-authored-by: Paul Ganssle <paul@ganssle.io>
Co-authored-by: Paul Ganssle <paul@ganssle.io>
* 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
* 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>
* 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
* 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
* 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
* from parsyfiles development (https://github.com/smarie/python-simple-file-collection-parsing-framework):
* added new 'chain' validator to allow users to chain their custom validators with, for example, 'instance_of'
* added utility methods to get the declared attribute type (by inspecting its validators) and to check if it is optional
* from parsyfiles development (https://github.com/smarie/python-simple-file-collection-parsing-framework):
* added tests
* fixed bug with optional validator to pass tests :)
* from parsyfiles development (https://github.com/smarie/python-simple-file-collection-parsing-framework):
* completed doc api.rst
* small mod in tests
* Fixed issue with empty cell in closure when slots are used. Fixed#589
* Removed api.rst mods erroneously injected from another branch.
* Removed api.rst mods erroneously injected from another branch.
* noqa so that flake8 is happy
* Fixed lint error
* Added towncrier changelog entry
* Attempt to fix linter error
* Update tests/test_slots.py
* Last lint fix
* Update changelog.d/590.change.rst
Co-Authored-By: Hynek Schlawack <hs@ox.cx>
* Added extensive doc in the new test
* Update tests/test_slots.py
* last lint error
Co-authored-by: Sylvain MARIE <sylvain.marie@se.com>
Co-authored-by: Hynek Schlawack <hs@ox.cx>
* Use an self-clearing subclass to store hash cache
Rather than attempting to remove the hash cache from the object state on
deserialization or serialization, instead we store the hash cache in an
object that reduces to None, thus clearing itself when pickled or
copied.
This fixes GH #494 and #613.
Co-authored-by: Matt Wozniski <godlygeek@gmail.com>
* Add test for two-argument __reduce__
I couldn't think of any way to make a useful and meaningful class that
has no state and also has no custom __reduce__ method, so I went
minimalist with it.
* Improve test for hash clearing behavior.
Previously, there was some miniscule risk of hash collision, and also it
was relying on the implementation details of `pickle` (the assumption
that `hash()` is never called as part of `pickle.loads`).
* Add improved testing around cache_hash
* Update src/attr/_make.py
Co-Authored-By: Ryan Gabbard <gabbard@isi.edu>
* Update comment in slots_setstate
Since the cached hash value is not actually serialized in __getstate__,
__setstate__ is not actually "clearing" it on deserialization - it's
initializing the value to None.
* Add changelog entry
* Remove changelog for #611
This change was overshadowed by a more fundamental change in #620.
Co-authored-by: Matt Wozniski <godlygeek@gmail.com>
Co-authored-by: Ryan Gabbard <gabbard@isi.edu>
* Add xfailing test for frozen/cache_hash issue
This is a failing test for GH issue #611, with the xfail decorator to be
removed when the issue is fixed.
* Fix incompatibility between frozen and cache_hash
Fixes GH issue #611: serialization of a class with frozen=True and
cache_hash=True will now succeed rather than raising a
FrozenInstanceError.
Co-authored-by: Hynek Schlawack <hs@ox.cx>
* Add attr.__version_info__
This allows users to check for features and avoid deprecation warnings without
breaking backward compatibility.
* Add newsfragment
* Stay ASCII
* Typo
* Add stubs for _version.py
* Address David's feedback
* Handle PY2 better in comparability test
* drop the ing
* 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!