diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 34547655a589..a9109e454363 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,4 +40,38 @@ repos: rev: v2.2.4 hooks: - id: codespell - args: ['--ignore-words=doc/dictionary.txt'] \ No newline at end of file + 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 + ) diff --git a/mypy-files.txt b/mypy-files.txt deleted file mode 100644 index 391ed58d87b2..000000000000 --- a/mypy-files.txt +++ /dev/null @@ -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 diff --git a/setup.cfg b/setup.cfg index 5dd37efc6167..eceb6c4ab5fe 100644 --- a/setup.cfg +++ b/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 \ No newline at end of file +quiet-level = 4 diff --git a/test-requirements.txt b/test-requirements.txt index 8bada67d3ff1..04dcc056ee53 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -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 diff --git a/tools/mypywrap.sh b/tools/mypywrap.sh deleted file mode 100644 index dd5868d6e248..000000000000 --- a/tools/mypywrap.sh +++ /dev/null @@ -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 diff --git a/tox.ini b/tox.ini index c96276de2dad..852f12c14102 100644 --- a/tox.ini +++ b/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 =

AltStyle によって変換されたページ (->オリジナル) /