diff options
author | David Euresti <david@pilot.com> | 2020-12-20 21:21:28 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-21 06:21:28 +0100 |
commit | 3d274d0bfab142bc45504533f2c2b5f5ce519fd7 (patch) | |
tree | a754b439a4956dd517313267cce337a4d31ad8f2 | |
parent | 1c81e3ef7ec506f7e5a826ab65a4916c0386ec02 (diff) | |
download | attrs-3d274d0bfab142bc45504533f2c2b5f5ce519fd7.tar.gz |
WIP: Add mypy tests (#737)
* Add basic mypy tests
* Only run mypy on 3.6+
* No pypy
* Fix things
* Oooh parametrized
-rw-r--r-- | MANIFEST.in | 1 | ||||
-rw-r--r-- | setup.py | 8 | ||||
-rw-r--r-- | tests/test_mypy.yml | 23 |
3 files changed, 32 insertions, 0 deletions
diff --git a/MANIFEST.in b/MANIFEST.in index 46c9dbb..398252b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -8,6 +8,7 @@ recursive-include src *.pyi # Tests include tox.ini conftest.py recursive-include tests *.py +recursive-include tests *.yml # Documentation include docs/Makefile docs/docutils.conf @@ -1,6 +1,8 @@ import codecs import os +import platform import re +import sys from setuptools import find_packages, setup @@ -50,6 +52,12 @@ EXTRAS_REQUIRE = { "six", ], } +if ( + sys.version_info[:2] >= (3, 6) + and platform.python_implementation() != "PyPy" +): + EXTRAS_REQUIRE["tests_no_zope"].extend(["mypy", "pytest-mypy-plugins"]) + EXTRAS_REQUIRE["tests"] = EXTRAS_REQUIRE["tests_no_zope"] + ["zope.interface"] EXTRAS_REQUIRE["dev"] = ( EXTRAS_REQUIRE["tests"] + EXTRAS_REQUIRE["docs"] + ["pre-commit"] diff --git a/tests/test_mypy.yml b/tests/test_mypy.yml new file mode 100644 index 0000000..18128e6 --- /dev/null +++ b/tests/test_mypy.yml @@ -0,0 +1,23 @@ +- case: attr_s_with_type_argument + parametrized: + - val: 'a = attr.ib(type=int)' + - val: 'a: int = attr.ib()' + main: | + import attr + @attr.s + class C: + {{ val }} + C() # E: Too few arguments for "C" + C(1) + C(a=1) + C(a="hi") # E: Argument "a" to "C" has incompatible type "str"; expected "int" +- case: attr_s_with_type_annotations + main : | + import attr + @attr.s + class C: + a: int = attr.ib() + C() # E: Too few arguments for "C" + C(1) + C(a=1) + C(a="hi") # E: Argument "a" to "C" has incompatible type "str"; expected "int" |