From 9ba3ca6ce5013207737e431f52735c7eda3a2fbb Mon Sep 17 00:00:00 2001 From: Chris Patterson Date: Mon, 14 Feb 2022 12:09:01 -0500 Subject: mypy: introduce type checking (#1254) All currently failing modules are excluded from reporting errors using follow-imports=silent and an exclusion list. Future work can whittle down this failing list. This change will start enforcing new modules and those currently passing. Includes some minor alphabetical reordering in tox.ini. Signed-off-by: Chris Patterson --- tox.ini | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'tox.ini') diff --git a/tox.ini b/tox.ini index aab6d4d4..c494cb94 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py3, lowest-supported-dev, flake8, pylint, black, isort +envlist = py3, lowest-supported-dev, black, flake8, isort, mypy, pylint recreate = True [testenv] @@ -10,10 +10,15 @@ passenv= PYTEST_ADDOPTS [format_deps] -flake8==3.9.2 -pylint==2.11.1 black==21.12b0 +flake8==3.9.2 isort==5.10.1 +mypy==0.931 +pylint==2.11.1 +pytest==7.0.0 +types-PyYAML==6.0.4 +types-requests==2.27.8 +types-setuptools==57.4.9 [testenv:flake8] deps = @@ -37,18 +42,30 @@ deps = isort=={[format_deps]isort} commands = {envpython} -m isort . --check-only +[testenv:mypy] +deps = + mypy=={[format_deps]mypy} + types-pyyaml=={[format_deps]types-PyYAML} + types-requests=={[format_deps]types-requests} + types-setuptools=={[format_deps]types-setuptools} + pytest=={[format_deps]pytest} +commands = {envpython} -m mypy . + [testenv:check_format] deps = - flake8=={[format_deps]flake8} - pylint=={[format_deps]pylint} black=={[format_deps]black} + flake8=={[format_deps]flake8} isort=={[format_deps]isort} + mypy=={[format_deps]mypy} + pylint=={[format_deps]pylint} + pytest=={[format_deps]pytest} -r{toxinidir}/test-requirements.txt -r{toxinidir}/integration-requirements.txt commands = {[testenv:black]commands} - {[testenv:isort]commands} {[testenv:flake8]commands} + {[testenv:isort]commands} + {[testenv:mypy]commands} {[testenv:pylint]commands} [testenv:do_format] @@ -122,6 +139,15 @@ commands = commands = {envpython} -m flake8 {posargs:cloudinit/ tests/ tools/ setup.py} deps = flake8 +[testenv:tip-mypy] +commands = {envpython} -m mypy --install-types --non-interactive . +deps = + mypy + pytest + types-PyYAML + types-requests + types-setuptools + [testenv:tip-pylint] commands = {envpython} -m pylint {posargs:cloudinit tests tools} deps = -- cgit v1.2.1