Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy mypy and tox config #614

Merged
merged 15 commits into from
May 9, 2020
13 changes: 3 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,14 @@ matrix:
fast_finish: true

include:
- python: 3.6
- python: 3.7
name: Linting code style
env:
TOXENV: code-style
- python: 3.7
name: Linting type annotations
env:
TOXENV: typing
- python: &latest_py3 3.8

- python: 3.7
name: Making sure that docs build is healthy
env:
TOXENV: docs
- python: &latest_py3 3.8
- python: 3.7
- python: 3.6

- stage: deploy
if: tag IS present
Expand Down
4 changes: 2 additions & 2 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ Code style
^^^^^^^^^^

Run ``tox -e format`` to automatically reformat your changes. Run
``tox -e lint`` to see any remaining code smells or type errors that
need to be fixed manually.
``tox -e lint`` to see any remaining code smells that need to be
fixed manually.

Additionally, the Twine maintainers prefer that ``import`` statements
be used for packages and modules only, rather than individual classes
Expand Down
35 changes: 32 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[mypy]
show_traceback = True
; TODO: Make this more granular; docs recommend it as a "last resort"
; https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-type-hints-for-third-party-library
ignore_missing_imports = True

; --strict settings
warn_redundant_casts = True
Expand All @@ -20,3 +17,35 @@ no_implicit_optional = True
warn_return_any = True
no_implicit_reexport = True
strict_equality = True

[mypy-importlib_metadata]
; https://gitlab.com/python-devs/importlib_metadata/-/issues/10
ignore_missing_imports = True

[mypy-keyring]
; https://github.com/jaraco/keyring/issues/437
ignore_missing_imports = True

[mypy-pkginfo]
; https://bugs.launchpad.net/pkginfo/+bug/1876591
ignore_missing_imports = True

[mypy-requests_toolbelt,requests_toolbelt.*]
; https://github.com/requests/toolbelt/issues/279
ignore_missing_imports = True

[mypy-readme_renderer,readme_renderer.*]
; https://github.com/pypa/readme_renderer/issues/166
ignore_missing_imports = True

[mypy-setuptools]
; https://github.com/python/typeshed/issues/2171
ignore_missing_imports = True

[mypy-tqdm]
; https://github.com/tqdm/tqdm/issues/260
ignore_missing_imports = True

[mypy-urllib3]
; https://github.com/urllib3/urllib3/issues/867
ignore_missing_imports = True
56 changes: 24 additions & 32 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
minversion = 2.4
envlist = lint,docs,py38,py37,py36
envlist = py{36,37,38},docs

[testenv]
deps =
Expand All @@ -11,30 +11,35 @@ deps =
portend
pytest-services
munch
{[testenv:typing]deps}
{[testenv:lint]deps}
commands =
coverage run --source twine -m pytest {posargs:tests}
coverage run --source twine -m pytest tests
bhrutledge marked this conversation as resolved.
Show resolved Hide resolved
coverage report -m
coverage html
{[testenv:typing]commands}
bhrutledge marked this conversation as resolved.
Show resolved Hide resolved
{[testenv:lint]commands}

[testenv:docs]
[testenv:typing]
skip_install = True
deps =
-rdocs/requirements.txt
mypy
lxml
commands =
sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/_build/html
sphinx-build -W -b doctest -d {envtmpdir}/doctrees docs docs/_build/html
doc8 docs
sphinx-build -W -b linkcheck -d {envtmpdir}/doctrees docs docs/_build/linkcheck
python setup.py sdist
twine check dist/*
mypy --html-report mypy --txt-report mypy twine
python -c 'with open("mypy/index.txt") as f: print(f.read())'

[testenv:format]
skip_install = True
deps =
isort
black
commands =
isort --recursive twine/ tests/
black twine/ tests/

[testenv:code-style]
[testenv:lint]
skip_install = True
deps =
{[testenv:format]deps}
flake8
Expand All @@ -43,29 +48,16 @@ commands =
black --check --diff twine/ tests/
flake8 twine/ tests/

[testenv:typing]
deps =
mypy
lxml
commands =
# TODO: Consider checking the tests after the source is fully typed
mypy {posargs:--html-report mypy --txt-report mypy twine}

[testenv:monkeytype]
deps =
{[testenv]deps}
{[testenv:typing]deps}
monkeytype
commands =
monkeytype {posargs:run -m pytest}

[testenv:lint]
[testenv:docs]
deps =
{[testenv:code-style]deps}
{[testenv:typing]deps}
-rdocs/requirements.txt
commands =
{[testenv:code-style]commands}
{[testenv:typing]commands}
sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/_build/html
sphinx-build -W -b doctest -d {envtmpdir}/doctrees docs docs/_build/html
doc8 docs
sphinx-build -W -b linkcheck -d {envtmpdir}/doctrees docs docs/_build/linkcheck
python setup.py sdist
twine check dist/*

[testenv:release]
# disabled for twine to cause it to upload itself
Expand Down