diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 02377d2..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include attrs_strict/py.typed -recursive-include attrs_strict *.pyi -recursive-include attrs_strict *.py diff --git a/pyproject.toml b/pyproject.toml index 3cac81b..a0f4c3f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ build-backend = 'setuptools.build_meta' line-length = 80 [tool.setuptools_scm] -write_to = "attrs_strict/_version.py" +write_to = "src/attrs_strict/_version.py" write_to_template = """ \"\"\" Version information \"\"\" diff --git a/setup.cfg b/setup.cfg index 0896292..b59e676 100644 --- a/setup.cfg +++ b/setup.cfg @@ -34,12 +34,21 @@ project_urls = [options] packages = attrs_strict install_requires = - attrs - typing;python_version<'3.5' + attrs>=19.1.0 + typing>=3.7.4.1;python_version<'3.5' python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4 +package_dir = + =src tests_require = mock;python_version<'3.3' pytest >= 4 +[options.package_data] +* = *.pyi +attrs_strict = py.typed + +[options.packages.find] +where = src + [bdist_wheel] universal = true diff --git a/attrs_strict/__init__.py b/src/attrs_strict/__init__.py similarity index 100% rename from attrs_strict/__init__.py rename to src/attrs_strict/__init__.py diff --git a/types/__init__.pyi b/src/attrs_strict/__init__.pyi similarity index 100% rename from types/__init__.pyi rename to src/attrs_strict/__init__.pyi diff --git a/attrs_strict/_commons.py b/src/attrs_strict/_commons.py similarity index 100% rename from attrs_strict/_commons.py rename to src/attrs_strict/_commons.py diff --git a/types/_commons.pyi b/src/attrs_strict/_commons.pyi similarity index 100% rename from types/_commons.pyi rename to src/attrs_strict/_commons.pyi diff --git a/attrs_strict/_error.py b/src/attrs_strict/_error.py similarity index 100% rename from attrs_strict/_error.py rename to src/attrs_strict/_error.py diff --git a/types/_error.pyi b/src/attrs_strict/_error.pyi similarity index 100% rename from types/_error.pyi rename to src/attrs_strict/_error.pyi diff --git a/attrs_strict/_type_validation.py b/src/attrs_strict/_type_validation.py similarity index 98% rename from attrs_strict/_type_validation.py rename to src/attrs_strict/_type_validation.py index 98029aa..28026ca 100644 --- a/attrs_strict/_type_validation.py +++ b/src/attrs_strict/_type_validation.py @@ -74,9 +74,9 @@ def _validate_elements(attribute, value, expected_type): if base_type == typing.Any: return - if base_type != typing.Union and not isinstance( + if base_type != typing.Union and not isinstance( # type: ignore value, base_type - ): # type: ignore + ): raise AttributeTypeError(value, attribute) if base_type == typing.Union: # type: ignore diff --git a/types/_type_validation.pyi b/src/attrs_strict/_type_validation.pyi similarity index 100% rename from types/_type_validation.pyi rename to src/attrs_strict/_type_validation.pyi diff --git a/src/attrs_strict/_version.pyi b/src/attrs_strict/_version.pyi new file mode 100644 index 0000000..14a70ab --- /dev/null +++ b/src/attrs_strict/_version.pyi @@ -0,0 +1 @@ +__version__ : str= ... diff --git a/attrs_strict/py.typed b/src/attrs_strict/py.typed similarity index 100% rename from attrs_strict/py.typed rename to src/attrs_strict/py.typed diff --git a/tox.ini b/tox.ini index b182b6f..97be8ea 100644 --- a/tox.ini +++ b/tox.ini @@ -1,17 +1,16 @@ [tox] envlist = - py27, - py36, - py37, - py38, - pypy, - pypy3, - mypy, - coverage, - merge, - fix_lint, - docs, - package_description, + py27, + py36, + py37, + py38, + pypy, + pypy3, + coverage, + type, + fix_lint, + docs, + package_description, minversion = 3.7 isolated_build = true skip_missing_interpreters = true @@ -26,45 +25,31 @@ deps = pytest-cov py{27,py}: mock py{27,py}: typing - -changedir = tests -commands = python -m pytest \ +commands = pytest \ --cov attrs_strict \ --cov-config "{toxinidir}/tox.ini" \ --junitxml {toxworkdir}/junit.{envname}.xml \ - {posargs:.} - - -[testenv:mypy] -description = check that the type annotations within attrs-strict are self-consistent. Does NOT check if stub files align correctly with actual code. -basepython = python3.7 -deps = mypy -setenv = - {[testenv]setenv} - MYPYPATH={toxinidir} -commands = mypy types --py2 --strict - mypy types --strict + {posargs:tests} -[testenv:merge] +[testenv:type] description = try to merge our types against our source -deps = {[testenv:mypy]deps} - retype -changedir = {envtmpdir} -commands = python -m retype -p {toxinidir}/types -t {envtmpdir}/attrs_strict {toxinidir}/attrs_strict - mypy -p {envtmpdir}/attrs_strict --strict --ignore-missing-imports {posargs} +deps = + mypy == 0.770 + retype == 19.9.0 +commands = + retype -p src/attrs_strict src/attrs_strict -t {envtmpdir} + retype -p src/attrs_strict src/attrs_strict/_version.py -t {envtmpdir} + mypy {envtmpdir} --strict [testenv:docs] description = invoke sphinx-build to build the HTML docs -basepython = python3.7 deps = - sphinx + sphinx commands = sphinx-build -d "{toxworkdir}/docs_doctree" "{toxinidir}/doc" "{toxworkdir}/docs_out" --color -W -bhtml {posargs} python -c 'import pathlib; print("documentation available under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "docs_out" / "index.html"))' [testenv:package_description] -changedir = {toxinidir} description = check that the long description is valid -basepython = python3.7 deps = twine >= 1.12.1 readme-renderer[md] >= 24.0 pep517 @@ -73,7 +58,6 @@ commands = python -m pep517.build -s -b . -o {envtmpdir} twine check {envtmpdir}/* [testenv:pypi_publish] -changedir = {toxinidir} description = Upload a new package to pypi deps = twine >= 1.12.1 pep517 @@ -84,8 +68,6 @@ commands = python -m pep517.build -s -b . -o {envtmpdir} [testenv:fix_lint] description = format the code base to adhere to our styles, and complain about what we cannot do automatically -basepython = python3.7 -changedir = {toxinidir} passenv = {[testenv]passenv} # without PROGRAMDATA cloning using git for Windows will fail with an # `error setting certificate verify locations` error @@ -126,9 +108,12 @@ exclude_lines = ^if __name__ == ['"]__main__['"]:$ [coverage:paths] -source = attrs_strict +source = src/attrs_strict */.tox/*/lib/python*/site-packages/attrs_strict */.tox/pypy*/site-packages/attrs_strict */.tox\*\Lib\site-packages\attrs_strict */attrs_strict *\attrs_strict + +[pytest] +junit_family=xunit1