Skip to content

Commit

Permalink
Add initial mypy configuration
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Jussi Kukkonen committed May 17, 2021
1 parent 3e7c057 commit 2cc25e7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ coverage
black
isort
pylint
mypy
bandit
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 8 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2cc25e7

Please sign in to comment.