Commit Graph

89 Commits

Author SHA1 Message Date
Hynek Schlawack 45c263755f Move docs to 3.10 2021-11-29 09:04:06 +01:00
Hynek Schlawack 649a196877 Shuffle tox environments and Python versions a bit 2021-11-23 09:49:41 +01:00
Hynek Schlawack 675afb8f73 Don't run pre-commit in CI
We've got pre-commit.ci which is much better and faster.
2021-11-20 16:20:07 +01:00
Hynek Schlawack 9bb97cb58e
Repo Janitoring (#868)
* Use proper pypy versions

* Python 3.10 as main, better/more expressive names

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

* Ditch Codecov

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

* Don't need this anymore

* Streamline tox.ini

Signed-off-by: Hynek Schlawack <hs@ox.cx>
2021-11-19 14:51:46 +01:00
Hynek Schlawack 322e1904c1 Move docs to 3.8
This is the latest version currently supported by RTD.
2021-11-11 05:58:46 +01:00
Hynek Schlawack 2ca7aada70 Run pypy on pypy2 2021-08-07 08:53:10 +02:00
David Euresti fb154878eb
Fix mypy tests on 3.10 (#771)
Looks like this was a bug fixed upstream
2021-06-14 17:58:33 +00:00
Hynek Schlawack 6731eea0ed
Run Python 3.10 under coverage (#818)
Since the matching code is Python 3.10-specific, we run it under coverage.
2021-05-18 11:28:21 +02:00
Karthikeyan Singaravelan 8613af97bb
Add __match_args__ to support match case destructuring in Python 3.10 (#815)
* Add support to generate __match_args__ for Python 3.10.

* Add versionadded directive.

* Update stubs.

* Update changelog and add a test to typing examples.

* Fix error regarding new-style classes in Python 2.

* Fix lint error regarding line length.

* Fix lint error regarding trailing whitespace.

* Add docstrings for interrogate.

* Use _has_own_attribute instead of cls.__dict__ contains check.

* Update docs as per review comments.

* Revert mistaken changelog update.

* Add Python 3.10 pattern matching syntax test cases.

* Update define signature with match_args.

* Fix conftest formatting.

* Fix isort formatting.

* Bump to Python 3.10 to parse syntax.

* Bump basepython of lint to Python 3.10 for parsing.

* Move lint to py310

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2021-05-18 07:02:06 +02:00
Hynek Schlawack c5ae43f7f2 Pin towncrier
Currently the title is either not rendered at all, or rendered twice

cf.

- https://github.com/twisted/towncrier/issues/346
- https://github.com/twisted/towncrier/issues/340
2021-05-06 10:16:57 +02:00
Hynek Schlawack f41db43541 Unpin pyright & minor docs polish
ref #796
2021-05-05 16:06:09 +02:00
Alex Ford 7e372c56a2
Implement pyright support via dataclass_transforms (#796)
* Add __dataclass_transform__ decorator.

* Add doc notes for pyright dataclass_transform support.

* Fix docs build error.

* Expand docs on dataclass_transform

* Add changelog

* Fix docs build

* Fix lint

* Add note on __dataclass_transform__ in .pyi

* Add baseline test of pyright support via tox

* Add pyright tests to tox run configuration

* Fix test errors, enable in tox.

* Fixup lint

* Move pyright to py39

* Add test docstring.

* Fixup docs.

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2021-05-05 10:24:53 +02:00
Hynek Schlawack 03d3fc7a71
Add Python 3.10 support (#763)
* 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
2021-02-22 12:56:44 +01:00
Hynek Schlawack 68b5e048da mypy has caught up! Uncomment NG type tests 2021-01-29 10:29:17 +01:00
Hynek Schlawack 48755905ee
Don't reset custom __setattr__ in slotted classes (#681)
* 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>
2020-09-05 09:46:06 +02:00
Hynek Schlawack 1f67eefb4f Use pre-commit for interrogate 2020-08-25 12:37:54 +02:00
Hynek Schlawack 3a5b5a2052 Use interrogate's pyproject.toml support 2020-08-25 09:54:28 +02:00
Hynek Schlawack d4150f2114
Run CI against 3.9 pre-release (#664) 2020-08-13 13:58:58 +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 784179bab6
Use interrogate to enforce test docstrings
Signed-off-by: Hynek Schlawack <hs@ox.cx>
2020-05-03 12:24:28 +02:00
Hynek Schlawack 618373e335
Move to GitHub Actions (#633)
* Create main.yml

* Update tox.ini

* Update .readthedocs.yml

* Delete azure-pipelines.yml

* Update README.rst

* Update .pre-commit-config.yaml

* Update CONTRIBUTING.rst

* Update tox.ini
2020-03-13 11:07:31 +01:00
Hynek Schlawack ac541fbe55 Add version constraints for coverage 2020-01-09 12:34:38 +01:00
Hynek Schlawack 7edae2e070 Parallel is set by config 2020-01-08 22:02:39 +01:00
Hynek Schlawack 495968281c
Officially drop Python 3.4 (#608) 2020-01-06 12:32:28 +01:00
Hynek Schlawack 6fcb759862 Put coverage config into pyproject.toml 2020-01-06 09:14:24 +01:00
Hynek Schlawack e67cc51930 Unpin coverage
The problem was fixed in coverage 5.0.2.
2020-01-06 08:45:50 +01:00
Hynek Schlawack aa55c68efd Pin coverage to <5.0 for now
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.
2020-01-03 11:17:20 +01:00
Hynek Schlawack 0023e5bdce Ah, why not. pytest & tox are related 2019-10-17 12:46:22 +02:00
Hynek Schlawack 7b49d375c7 Rename _version.py into _version_info.py
Makes a lot more sense.
2019-10-02 16:12:03 +02:00
Hynek Schlawack 955d622493
Add attr.__version_info__ (#580)
* 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
2019-10-01 16:06:36 +02:00
David Euresti 08bbaabaca Fix some typing issues (#581)
* Typecheck stubs in CI and fix type errors.  Fixes #578

* Add overloads to instance_of definition.

Improves #576
2019-09-26 06:49:15 +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
Hynek Schlawack 4d03c7d69f Be explicit about 3.8 2019-06-04 11:09:42 +02:00
Hynek Schlawack 776d09dcc4 Run py38 under coverage too 2019-06-04 10:39:33 +02:00
Hynek Schlawack d6ca77a3ba Nicer env handling 2019-05-31 10:31:45 +02:00
Hynek Schlawack 729681b5a8
[WIP] Set up CI with Azure Pipelines (#510)
* Set up CI with Azure Pipelines

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update setup.py

* Update tox.ini

* Update setup.py

* Update azure-pipelines.yml

* Update setup.py

* Update azure-pipelines.yml

* Update azure-pipelines.yml for Azure Pipelines

* Delete .travis.yml

* Update README.rst

* Update azure-pipelines.yml

* Update azure-pipelines.yml
2019-05-08 16:13:55 -04:00
Hynek Schlawack de84609505 This is not accurate 2019-05-02 16:50:31 -04:00
Hynek Schlawack a35d8fb4c4 fix and simplify docs CI 2019-02-25 16:41:46 +01:00
Hynek Schlawack aa9f62f244 Use 3.7 for RTD 2019-02-25 16:28:53 +01:00
Hynek Schlawack 2f63f2c5fe
Use isolated builds (#499)
* Use isolated builds

* try to upgrade all the things

* Try to upgrade only setuptools
2019-02-09 18:36:30 +01:00
Hynek Schlawack f8f4aef5a8 Revert isolated builds because they break mypy 2019-02-09 14:48:06 +01:00
Hynek Schlawack d4a002f64d try to fix build 2019-02-09 14:28:01 +01:00
Hynek Schlawack d21eed5165 Use isolated builds 2019-02-09 13:59:26 +01:00
Hynek Schlawack af35f2a57e RTD uses 3.5, so should we
We split up building of docs and doctest because RTD doesn't allow newer than
3.5 but we need up to date Python versions for our doctests.
2019-01-17 10:46:14 +01:00
Hynek Schlawack cfac7463c1 Fix deprecation warning for PyPI description check 2018-11-26 17:30:27 +01:00
Hynek Schlawack 3f59f08625 Fix double entry in pre-commit config 2018-11-26 12:58:39 +01:00
Hynek Schlawack a7db21a273 More pre-commit, more 3.7, more linting, more stages 2018-11-24 13:36:20 +01:00
Hynek Schlawack 290cf2a3f0 Quench a bunch of warnings 2018-10-19 10:48:09 +02:00
Chad Dombrova de104e016b Add PEP484 stubs (#238)
* 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
2018-07-12 12:19:24 +02:00
Hynek Schlawack 2d71759098
Run on 3.7 proper (#405) 2018-07-05 07:39:16 +02:00