* 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>
* Wrapped __ne__ in a _make_ne function to guarantee that each attrs class gets a new instance of the __ne__ function
* Changed _make_eq to return just __eq__ instead of __eq__ and __ne__
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>
* 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
Getting
```
Coverage.py warning: Module attr was previously imported, but not measured (module-not-measured)
```
and missing coverage for some reason. Google is not helpful.