* Add Python 3.10 support
Python 3.10 has string types everywhere and that has unmasked a bunch of
bugs/edge cases in our code.
Especially the hooks code need a resolving helper for string types. I'm leaving
that for a separate PR.
Fixes#716
* More robust quote handling
* Use resolve_types decorator where possible
* Use a helper for __init__ annotations
* Add test for various ClassVars
* 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 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
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.
* 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
* 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.
* Add PEP484 stubs
* Deploy .pyi stubs alongside .py files.
This is the recommended approach for 3rd party stubs.
See: https://github.com/python/typing/issues/84#issuecomment-317217346
* Add support for the new type argument.
* Add tests for stubs and address a few issues.
* Improve declaration of private vs public objects in stubs
* More stub tests
* Separate the stub tests into their own tox env
it does not make sense to test the stubs in multiple python *runtime* environments (e.g. python 3.5, 3.6, pypy3) because the results of static analysis wrt attrs is not dependent on the runtime. Moreover, mypy is not installing correctly in pypy3 which has nothing to do with attrs.
* Update the manifest with stub files
* Remove mypy from the dev requirements
* Allow _CountingAttr to be instantiated, but not Attribute.
* Incorporate defaults into attr.ib typing
* Fix a bug with validators.and_
* Add more tests
* Remove _CountingAttr from public interface
It is crucial to ensure that make_class() works with attr.ib(), as a result we no longer have any functions that care about _CountingAttr.
* Lie about return type of Factory
this allows for an abbreviated idiom: `x: List[int] = Factory(list)`
* Add tox stubs env to travis
* used the wrong comment character in mypy tests
* Improve overloads using PyCharm order-based approach
overloads are pretty broken in mypy. the best we can do for now is target PyCharm, which is much more forgiving.
* Remove features not yet working in mypy. Document remaining issues.
* Test stubs against euresti fork of mypy with attrs plugin
Copied the pytest plugin from mypy for testing annotations: It is not an officially supported API and using the plugin from mypy could break after any update.
* Add some types and TypeVars to some types. Make tests pass
* Suppress warnings about named attribute access from fields()
e.g. fields(C).x
Eventually it would be good to add support for returning NamedTuple from the mypy plugin
* Add WIP mypy-doctest plugin
* Deal with a few remaining type issues in the docs
* sphinx doctest: don't turn warnings into errors.
doing so makes the tests abort after the first failed group.
* Update "type: ignore" comments to reflect issues fixed in mypy plugin
* doctest2: improve output formatting
* Update manifest
* static tests: use inline error declarations
* More tests
* Tests passing (with notes about remaining issues)
* Attempt to get latest plugin from euresti working
* Issues fixed.
Had to place calls to attr.ib under a class definition.
* Deal with a PyCharm bug
* Minor test improvements
* Make tests prettier
* Use 2 decorators instead of 3
* doctest2: add support for skipping mypy tests
* Add tests for inheritance, eq, and cmp
* Add fixmes and todos
* Rename convert to converter
* Attribute.validator is always a single validator
* Conform stubs to typeshed coding style
And add auto_attrib kw
* backport style fixes from typeshed
* Add test cases to cover forward references and Any
* Add fixes for forward references and Any
* Address typeshed review notes
* Use Sequence instead of List/Tuple for validator arg
list and tuple are invariant and so prevent passing subtypes of _ValidatorType
* backports changes from typeshed #1914
* backport changes from typeshed #1933
* Prevent mypy tests from getting picked up
Evidently the discovery rules changed recently for pytest.
* make our doctest extension compatible with latest sphinx
* Adjustments to the tests
* Fix flake and manifest tests (hopefully)
* Fix tests on pypy3 (hopefully)
* Update stubs from typeshed
Also update tests.
* Make PEP 561-compliant
* minor cleanup
* Consolidate stub support files into stub directory
In preparation for removing them from the pyi_stubs branch.
* Get tests passing
This is a final test of the current stubs before moving the stub tests to a new branch.
* Revert stub test additions
Replace with a simple mypy pass/fail test
* get pre-commit passing
* Address review feedback
* Move typing test up in tox envlist