Run mypy as pre-commit

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.

Change-Id: Id58fb9e8ea454c10e502c96ad4c36788e7533318
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2023-07-25 12:34:40 +01:00
parent 2a8627d4f1
commit c9a877e2de
2 changed files with 88 additions and 0 deletions

View File

@ -37,3 +37,46 @@ repos:
entry: flake8
files: '^.*\.py$'
exclude: '^(doc|releasenotes|tools)/.*$'
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
hooks:
- id: mypy
additional_dependencies:
- types-decorator
- types-PyYAML
- types-requests
- types-simplejson
# keep this in-sync with '[mypy] exclude' in 'setup.cfg'
exclude: |
(?x)(
openstack/tests/ansible/.*
| openstack/tests/functional/.*
| openstack/tests/unit/.*
| openstack/tests/fixtures.py
| openstack/accelerator/.*
| openstack/baremetal/.*
| openstack/baremetal_introspection/.*
| openstack/block_storage/.*
| openstack/cloud/.*
| openstack/clustering/.*
| openstack/compute/.*
| openstack/container_infrastructure_management/.*
| openstack/database/.*
| openstack/dns/.*
| openstack/fixture/.*
| openstack/identity/.*
| openstack/image/.*
| openstack/instance_ha/.*
| openstack/key_manager/.*
| openstack/load_balancer/.*
| openstack/message/.*
| openstack/network/.*
| openstack/object_store/.*
| openstack/orchestration/.*
| openstack/placement/.*
| openstack/shared_file_system/.*
| openstack/workflow/.*
| doc/.*
| examples/.*
| releasenotes/.*
)

View File

@ -28,3 +28,48 @@ packages =
[entry_points]
console_scripts =
openstack-inventory = openstack.cloud.cmd.inventory:main
[mypy]
show_column_numbers = true
show_error_context = true
ignore_missing_imports = true
# follow_imports = normal
follow_imports = skip
incremental = true
check_untyped_defs = true
warn_unused_ignores = true
# keep this in-sync with 'mypy.exclude' in '.pre-commit-config.yaml'
# TODO(stephenfin) Eventually we should remove everything here except the
# unit tests module
exclude = (?x)(
openstack/tests/ansible
| openstack/tests/functional
| openstack/tests/unit
| openstack/tests/fixtures.py
| openstack/accelerator
| openstack/baremetal
| openstack/baremetal_introspection
| openstack/block_storage
| openstack/cloud
| openstack/clustering
| openstack/compute
| openstack/container_infrastructure_management
| openstack/database
| openstack/dns
| openstack/fixture
| openstack/identity
| openstack/image
| openstack/instance_ha
| openstack/key_manager
| openstack/load_balancer
| openstack/message
| openstack/network
| openstack/object_store
| openstack/orchestration
| openstack/placement
| openstack/shared_file_system
| openstack/workflow
| doc
| examples
| releasenotes
)