From ca5f2ddd9c22c380fd644fa0d439f77aac764d7c Mon Sep 17 00:00:00 2001 From: Jussi Kukkonen Date: Mon, 10 May 2021 13:19:45 +0300 Subject: [PATCH] Add initial mypy configuration This is an initial setup: By default check only tuf/api/, and ignore securesystemslib imports. Change lint working directory to source root: This saves repeating a lot of {toxinidir} in the command lines. Signed-off-by: Jussi Kukkonen --- requirements-test.txt | 1 + setup.cfg | 7 +++++++ tox.ini | 13 ++++++++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/requirements-test.txt b/requirements-test.txt index 65646ca2..692d5395 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -11,4 +11,5 @@ coverage black isort pylint +mypy bandit diff --git a/setup.cfg b/setup.cfg index 1ffc5648..0b65c06a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,3 +6,10 @@ ignore = requirements-dev.txt .travis.yml .coveragerc + +[mypy] +warn_unused_configs = True +files = tuf/api/ + +[mypy-securesystemslib.*] +ignore_missing_imports = True diff --git a/tox.ini b/tox.ini index d3ea4f94..84d1c87b 100644 --- a/tox.ini +++ b/tox.ini @@ -39,15 +39,18 @@ commands = python -m coverage report -m [testenv:lint] +changedir = {toxinidir} commands = # Use different configs for new (tuf/api/*) and legacy code # TODO: configure black and isort args in pyproject.toml (see #1161) - black --check --diff --line-length 80 {toxinidir}/tuf/api - isort --check --diff --line-length 80 --profile black -p tuf {toxinidir}/tuf/api - pylint {toxinidir}/tuf/api --rcfile={toxinidir}/tuf/api/pylintrc + black --check --diff --line-length 80 tuf/api + isort --check --diff --line-length 80 --profile black -p tuf tuf/api + pylint tuf/api --rcfile=tuf/api/pylintrc # NOTE: Contrary to what the pylint docs suggest, ignoring full paths does # work, unfortunately each subdirectory has to be ignored explicitly. - pylint {toxinidir}/tuf --ignore={toxinidir}/tuf/api,{toxinidir}/tuf/api/serialization + pylint tuf --ignore=tuf/api,tuf/api/serialization - bandit -r {toxinidir}/tuf + mypy + + bandit -r tuf