pre-commit: Add mypy
Add mypy so we can run these checks as part of our linting step. Note that mypy is the last item in the list of checks since flake8 is going to catch e.g. syntax issues which should be addressed first. This also allows us to drop use of mypywrap: rather than wrapping mypy, we can make use of mypy's configuration to specify the files we wish to run checks on. Change-Id: Ie51401ead4e31ccd70ab833c59cb397f802ff188 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
80a2b018df
commit
e3e35ba2d0
@ -40,4 +40,38 @@ repos:
|
||||
rev: v2.2.4
|
||||
hooks:
|
||||
- id: codespell
|
||||
args: ['--ignore-words=doc/dictionary.txt']
|
||||
args: ['--ignore-words=doc/dictionary.txt']
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: v1.4.1
|
||||
hooks:
|
||||
- id: mypy
|
||||
additional_dependencies:
|
||||
- types-paramiko
|
||||
# keep this in-sync with '[mypy] files' in 'setup.cfg'
|
||||
files: |
|
||||
(?x)(
|
||||
nova/compute/manager.py
|
||||
| nova/compute/pci_placement_translator.py
|
||||
| nova/crypto.py
|
||||
| nova/filesystem.py
|
||||
| nova/limit/local.py
|
||||
| nova/limit/placement.py
|
||||
| nova/network/neutron.py
|
||||
| nova/pci
|
||||
| nova/privsep/path.py
|
||||
| nova/scheduler/client/report.py
|
||||
| nova/scheduler/request_filter.py
|
||||
| nova/scheduler/utils.py
|
||||
| nova/virt/driver.py
|
||||
| nova/virt/hardware.py
|
||||
| nova/virt/libvirt/machine_type_utils.py
|
||||
| nova/virt/libvirt/__init__.py
|
||||
| nova/virt/libvirt/cpu/__init__.py
|
||||
| nova/virt/libvirt/cpu/api.py
|
||||
| nova/virt/libvirt/cpu/core.py
|
||||
| nova/virt/libvirt/driver.py
|
||||
| nova/virt/libvirt/event.py
|
||||
| nova/virt/libvirt/guest.py
|
||||
| nova/virt/libvirt/host.py
|
||||
| nova/virt/libvirt/utils.py
|
||||
)
|
||||
|
@ -1,24 +0,0 @@
|
||||
nova/compute/manager.py
|
||||
nova/compute/pci_placement_translator.py
|
||||
nova/crypto.py
|
||||
nova/filesystem.py
|
||||
nova/limit/local.py
|
||||
nova/limit/placement.py
|
||||
nova/network/neutron.py
|
||||
nova/pci
|
||||
nova/privsep/path.py
|
||||
nova/scheduler/client/report.py
|
||||
nova/scheduler/request_filter.py
|
||||
nova/scheduler/utils.py
|
||||
nova/virt/driver.py
|
||||
nova/virt/hardware.py
|
||||
nova/virt/libvirt/machine_type_utils.py
|
||||
nova/virt/libvirt/__init__.py
|
||||
nova/virt/libvirt/cpu/__init__.py
|
||||
nova/virt/libvirt/cpu/api.py
|
||||
nova/virt/libvirt/cpu/core.py
|
||||
nova/virt/libvirt/driver.py
|
||||
nova/virt/libvirt/event.py
|
||||
nova/virt/libvirt/guest.py
|
||||
nova/virt/libvirt/host.py
|
||||
nova/virt/libvirt/utils.py
|
27
setup.cfg
27
setup.cfg
@ -101,8 +101,33 @@ follow_imports = skip
|
||||
incremental = true
|
||||
check_untyped_defs = true
|
||||
warn_unused_ignores = true
|
||||
files =
|
||||
nova/compute/manager.py,
|
||||
nova/compute/pci_placement_translator.py,
|
||||
nova/crypto.py,
|
||||
nova/filesystem.py,
|
||||
nova/limit/local.py,
|
||||
nova/limit/placement.py,
|
||||
nova/network/neutron.py,
|
||||
nova/pci/*.py,
|
||||
nova/privsep/path.py,
|
||||
nova/scheduler/client/report.py,
|
||||
nova/scheduler/request_filter.py,
|
||||
nova/scheduler/utils.py,
|
||||
nova/virt/driver.py,
|
||||
nova/virt/hardware.py,
|
||||
nova/virt/libvirt/machine_type_utils.py,
|
||||
nova/virt/libvirt/__init__.py,
|
||||
nova/virt/libvirt/cpu/__init__.py,
|
||||
nova/virt/libvirt/cpu/api.py,
|
||||
nova/virt/libvirt/cpu/core.py,
|
||||
nova/virt/libvirt/driver.py,
|
||||
nova/virt/libvirt/event.py,
|
||||
nova/virt/libvirt/guest.py,
|
||||
nova/virt/libvirt/host.py,
|
||||
nova/virt/libvirt/utils.py
|
||||
|
||||
[codespell]
|
||||
skip = *.po,*.js,*.css,*.html,*.svg,HACKING.py,*hacking*,*build*,*_static*,doc/dictionary.txt,*.pyc,*.inv,*.gz,*.jpg,*.png,*.vsd,*.graffle,*.json
|
||||
count =
|
||||
quiet-level = 4
|
||||
quiet-level = 4
|
||||
|
@ -1,6 +1,4 @@
|
||||
hacking==6.1.0 # Apache-2.0
|
||||
mypy>=0.761 # MIT
|
||||
types-paramiko>=0.1.3 # Apache-2.0
|
||||
coverage!=4.4,>=4.0 # Apache-2.0
|
||||
ddt>=1.2.1 # MIT
|
||||
fixtures>=3.0.0 # Apache-2.0/BSD
|
||||
|
@ -1,22 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# A wrapper around mypy that allows us to specify what files to run 'mypy' type
|
||||
# checks on. Intended to be invoked via tox:
|
||||
#
|
||||
# tox -e mypy
|
||||
#
|
||||
# Eventually this should go away once we have either converted everything or
|
||||
# converted enough and ignored [1] the rest.
|
||||
#
|
||||
# [1] http://mypy.readthedocs.io/en/latest/config_file.html#per-module-flags
|
||||
|
||||
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
# if no arguments provided, use the standard converted lists
|
||||
lines=$(grep -v '#' $ROOT_DIR/../mypy-files.txt)
|
||||
python -m mypy ${lines[@]}
|
||||
else
|
||||
# else test what the user asked us to
|
||||
python -m mypy $@
|
||||
fi
|
17
tox.ini
17
tox.ini
@ -99,14 +99,6 @@ extras =
|
||||
commands =
|
||||
stestr --test-path=./nova/tests/functional run --exclude-regex '((?:api|notification)_sample_tests|functional\.db\.)' {posargs}
|
||||
|
||||
[testenv:mypy]
|
||||
description =
|
||||
Run type checks.
|
||||
envdir = {toxworkdir}/shared
|
||||
extras =
|
||||
commands =
|
||||
bash tools/mypywrap.sh {posargs}
|
||||
|
||||
[testenv:pep8]
|
||||
description =
|
||||
Run style checks.
|
||||
@ -116,6 +108,15 @@ extras =
|
||||
commands =
|
||||
pre-commit run --all-files --show-diff-on-failure
|
||||
|
||||
[testenv:mypy]
|
||||
description =
|
||||
Run type checks.
|
||||
deps =
|
||||
pre-commit
|
||||
extras =
|
||||
commands =
|
||||
pre-commit run --all-files --show-diff-on-failure mypy
|
||||
|
||||
[testenv:autopep8]
|
||||
extras =
|
||||
deps =
|
||||
|
Loading…
x
Reference in New Issue
Block a user