* add new validators from #425 to validators.__all__
* add test for each validator, verifying that it is in validators.__all__
* add changelog entry for #517
* apply autolinting
* Make module path absolute
* Remove code and tests related to deprecated 'convert' kwarg
* Updated documentation, added changelog.d entry
* Fix attrib signature in docstring
* Update docstring version number for removal of 'convert' kw argument in attrib
* Implement first class exception support
Fixes#368
* Ensure single-attrib classes work too
cf https://github.com/python-attrs/attrs/pull/500#pullrequestreview-201913569
* Call into BaseException to initialiaze self.args
* Leave __str__ alone since we upcall
Based on Python pizza hallway feedback by @ambv.
* remove stray stage
* nope
* Clarify documentation for hashing
Makes clear that hashable objects need to be deeply immutable, in
practice even if not in theory.
Closes#503 .
* Use simple past tense in docs
* Don't cache hash codes across deserialization.
Because the hash code cache field gets serialized and deserialized by
Pickle, previously when you deserialize a cache_hash=True attrs object, the
hashcode will be the hashcode the object had at serialization-time.
However, if your object had fields with hash codes which were not
deterministic between interpreter runs, then on a new interpreter run
your deserialized object would have a hash code which differs from a
newly created identical object.
This commit fixes that by clearing the cache on deserialization. It
needs to override the __setstate__ method to do so, so this commit
also forbids using a custom __setstate__ on a cache_hash=True object.
Closes#482 .
* Improve exception type
* Minor tweaks to comments formatting
* Fix test for Python 2.7
* Fix error in comment
* Make nomenclature consistent for slotted/dict classes
* Remove hasattr()
* Improve comments and error message for custom __setstate__ + cache_hash=True
* Drop use of for test classes for cache hash serialization
* Make changelog note this is a breaking change
* Make exception message point to tracking issue
* Fix test classes for Python 2.7
* Allow init=False attributes to follow kw_only attributes
Closes#450
* Fix changelog typo
* Update reference text for exception message
* Remove type annotations from tests
* Fix long docstring lines
* Add test with literal default
* initial implementation of deep validators for iterables and dictionaries
* initial implementation of is_callable validator
* add versionadded for deep validators
* add versionadded for is_callable validator
* add tests for is_callable validator
* tweak _DeepIterable repr
* add tests for deep_iterable
* add to _DeepDictionary an initial validation that the top-level value is in fact a dictionary
* add tests for deep_dictionary validator
* apply precommit hooks
* refactor deep_dictionary to deep_mapping with optional mapping validator
* move is_callable validator up in module to allow deep validators to use it
* complete conversion from "deep dictionary" to "deep mapping"
* add changelog.d entry for #425
* fix rst formatting and normalize to semantic newlines
* add "instance_of", "deep_iterable", and "deep_mapping" validators to docs/api.rst
* add "serve-docs" tox environment to preview rendered sphinx docs
* bump versionadded for is_callable and deep validators to 18.3.0
* linting cleanup
* Revert "add "serve-docs" tox environment to preview rendered sphinx docs"
This reverts commit a2df89b788fdc31b54e604095c166b6a37c56f19.
* fix error message broken in linting fix
* Add weakref parameter to attr.s()
#325
* Add weakref to simple_classes() strategy
* Rename changelog file with actual PR (420.change.rst)
* Add test_weakref_does_not_add_a_field()
* Add docstrings to new weakref tests
* Add missing blank line
* Correct weakref handling of __weakref__ attributes or an inherrited slot
* Correct typos and terms
* Rename to weakref_slot
* Parametrize more tests against weakref_slot True/False to expose trouble
* Check if __weakref__ has been inherited via a __dict__
* Correct copy/pasted comment
* Change weakref_slot default to True
* Tidy and correct weakref -> weakref_slot
* First stab at implementing hashcode caching (#423)
Currently all existing tests pass but no cache_hash tests have yet
been added.
* Existing hash tests now pass on cache_hash classes
* Add towncrier change log
* Add documentation for cache_hash
* Fixes bug with check that init=True if cache_hash=True
* Fix long lines
* Fix documentation issues
* Add test for cache_hash requiring init
* Improve test coverage
* Remove now unnecessary 'pass'
* Add periods to the end of exception strings
* Add test docstrings for cache_hash tests
* Clarify documentation of cache_hash
* Recommend that hashable classes be frozen
* Fix test references for exception messages
* Added support for keyword-only attributes. Closes#106, and closes#38
(Rebases #281)
Co-authored-by: Alex Ford <fordas@uw.edu>
* Add `attr.s`-level `kw_only` flag.
Add `kw_only` flag to `attr.s` decorator, indicating that all class
attributes should be keyword-only in __init__.
Minor updates to internal interface of `Attribute` to support
evolution of attributes to `kw_only` in class factory.
Expand examples with `attr.s` level kw_only.
* Add `kw_only` to type stubs.
* Update changelog for rebased PR.
Hear ye, hear ye. A duplicate PR is born.
* Tidy docs from review.
* Tidy code from review.
* Add explicit tests of PY2 kw_only SyntaxError behavior.
* Add `PythonToOldError`, raise for kw_only on PY2.
* `Attribute._evolve` to `Attribute._assoc`.
self._cls_dict["__weakref__"] holds a reference to self._cls, preventing
self._cls from being released after the new, slots-enabled class is
returned.
Fixes#407
* Improve error for in_(a_string) with a non-string value
* Tighten exception handling and test description
* Improve changelog for Hynek
* Final changelog edit
* Add narrative chapter on initialization
* Be more explicit about defining validators both ways
* Stress that the name of default/validator != attr name
* Mention nested schemas
* Explain handling of private attributes
* Add another consequence of _ stripping
* Stress that nothing should overwrite attributes on class body
* Better wording
* typo
* Dedup examples
* Address review feedback
* Add newsfragments
* Annotate __init__ with type hints
This just adds the annotations found at run-time to the
`__annotations__` attribute of the created `__init__` function
Fixes#249
* More tests. Add return annotation
* Documentation
* This is not markdown
* Retain order if these or make_class are passed an ordered dict
Fixes#339
* Add newsfragment
* Another newsfragment
Fixes#300
* Docs and change tags
* Disable coverage and explain why
* PyPy has ordered dicts too
* Import OrderedDict only when necessary
* Make cell setting completely best effort
We just try, catch any exception and warn if it doesn't work on a Python 3.
Should cover edge cases such as Jython or GAE.
Fixes#321
* Add news fragment
* Typing is hard yo
* Make _CountingAttr empty metadata unique
Issue #278
* Correct st.none().map() to st.builds()
* Add 'real' and 'force coverage' tests for not None metadata
* Add changelog for pr 280
* Correct import order in tests/test_make.py
* Add back coverage force test
* Remove debug print from test/utils.py
* Fix and accelerate generated __hash__ methods
We now create a method like we do for __init__ and hash also the class of the
instance.
* Add/fix news fragments
* Hash random numbers instead of the actual class
* Even simpler: let's hash the unique filename
Or rather it's hash, because hashing ints is very fast.
* Stop setting attributes on class bodies
This behavior has been deprecated since 16.1 and can now be removed in
accordance with our backward-compatibility policy.
* We don't need iterkeys anymore
* Add support for passing a type to attr.ib() and gathering the type from PEP526-style annotations.
* Address review notes.
* More review notes.
* A few more review changes.
* Quick final fix to the changelog.