Skip to content

Commit

Permalink
Fix type packagings
Browse files Browse the repository at this point in the history
Signed-off-by: Bernat Gabor <[email protected]>
  • Loading branch information
gaborbernat committed May 31, 2020
1 parent 8c40bd3 commit 118f266
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 49 deletions.
3 changes: 0 additions & 3 deletions MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \"\"\"
Expand Down
13 changes: 11 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/attrs_strict/_version.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ : str= ...
File renamed without changes.
67 changes: 26 additions & 41 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 118f266

Please sign in to comment.