Skip to content

Commit e3e35ba

Browse files
stephenfinSeanMooney
authored andcommitted
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 <[email protected]>
1 parent 80a2b01 commit e3e35ba

File tree

6 files changed

+69
-57
lines changed

6 files changed

+69
-57
lines changed

.pre-commit-config.yaml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,38 @@ repos:
4040
rev: v2.2.4
4141
hooks:
4242
- id: codespell
43-
args: ['--ignore-words=doc/dictionary.txt']
43+
args: ['--ignore-words=doc/dictionary.txt']
44+
- repo: https://github.com/pre-commit/mirrors-mypy
45+
rev: v1.4.1
46+
hooks:
47+
- id: mypy
48+
additional_dependencies:
49+
- types-paramiko
50+
# keep this in-sync with '[mypy] files' in 'setup.cfg'
51+
files: |
52+
(?x)(
53+
nova/compute/manager.py
54+
| nova/compute/pci_placement_translator.py
55+
| nova/crypto.py
56+
| nova/filesystem.py
57+
| nova/limit/local.py
58+
| nova/limit/placement.py
59+
| nova/network/neutron.py
60+
| nova/pci
61+
| nova/privsep/path.py
62+
| nova/scheduler/client/report.py
63+
| nova/scheduler/request_filter.py
64+
| nova/scheduler/utils.py
65+
| nova/virt/driver.py
66+
| nova/virt/hardware.py
67+
| nova/virt/libvirt/machine_type_utils.py
68+
| nova/virt/libvirt/__init__.py
69+
| nova/virt/libvirt/cpu/__init__.py
70+
| nova/virt/libvirt/cpu/api.py
71+
| nova/virt/libvirt/cpu/core.py
72+
| nova/virt/libvirt/driver.py
73+
| nova/virt/libvirt/event.py
74+
| nova/virt/libvirt/guest.py
75+
| nova/virt/libvirt/host.py
76+
| nova/virt/libvirt/utils.py
77+
)

mypy-files.txt

Lines changed: 0 additions & 24 deletions
This file was deleted.

setup.cfg

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,33 @@ follow_imports = skip
101101
incremental = true
102102
check_untyped_defs = true
103103
warn_unused_ignores = true
104+
files =
105+
nova/compute/manager.py,
106+
nova/compute/pci_placement_translator.py,
107+
nova/crypto.py,
108+
nova/filesystem.py,
109+
nova/limit/local.py,
110+
nova/limit/placement.py,
111+
nova/network/neutron.py,
112+
nova/pci/*.py,
113+
nova/privsep/path.py,
114+
nova/scheduler/client/report.py,
115+
nova/scheduler/request_filter.py,
116+
nova/scheduler/utils.py,
117+
nova/virt/driver.py,
118+
nova/virt/hardware.py,
119+
nova/virt/libvirt/machine_type_utils.py,
120+
nova/virt/libvirt/__init__.py,
121+
nova/virt/libvirt/cpu/__init__.py,
122+
nova/virt/libvirt/cpu/api.py,
123+
nova/virt/libvirt/cpu/core.py,
124+
nova/virt/libvirt/driver.py,
125+
nova/virt/libvirt/event.py,
126+
nova/virt/libvirt/guest.py,
127+
nova/virt/libvirt/host.py,
128+
nova/virt/libvirt/utils.py
104129

105130
[codespell]
106131
skip = *.po,*.js,*.css,*.html,*.svg,HACKING.py,*hacking*,*build*,*_static*,doc/dictionary.txt,*.pyc,*.inv,*.gz,*.jpg,*.png,*.vsd,*.graffle,*.json
107132
count =
108-
quiet-level = 4
133+
quiet-level = 4

test-requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
hacking==6.1.0 # Apache-2.0
2-
mypy>=0.761 # MIT
3-
types-paramiko>=0.1.3 # Apache-2.0
42
coverage!=4.4,>=4.0 # Apache-2.0
53
ddt>=1.2.1 # MIT
64
fixtures>=3.0.0 # Apache-2.0/BSD

tools/mypywrap.sh

Lines changed: 0 additions & 22 deletions
This file was deleted.

tox.ini

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,22 +99,23 @@ extras =
9999
commands =
100100
stestr --test-path=./nova/tests/functional run --exclude-regex '((?:api|notification)_sample_tests|functional\.db\.)' {posargs}
101101

102-
[testenv:mypy]
102+
[testenv:pep8]
103103
description =
104-
Run type checks.
105-
envdir = {toxworkdir}/shared
104+
Run style checks.
105+
deps =
106+
pre-commit
106107
extras =
107108
commands =
108-
bash tools/mypywrap.sh {posargs}
109+
pre-commit run --all-files --show-diff-on-failure
109110

110-
[testenv:pep8]
111+
[testenv:mypy]
111112
description =
112-
Run style checks.
113+
Run type checks.
113114
deps =
114115
pre-commit
115116
extras =
116117
commands =
117-
pre-commit run --all-files --show-diff-on-failure
118+
pre-commit run --all-files --show-diff-on-failure mypy
118119

119120
[testenv:autopep8]
120121
extras =

0 commit comments

Comments
 (0)