Run mypy from tox
This avoids the need to duplicate our dependency list in multiple places and allows us to take advantage of tox's dependency management infrastructure, to ensure we always get the latest and greatest version of a package allowed by upper-constraints. While here, we also update the versions of the remaining pre-commit hooks and change the indentation of the tox file to align with the two indent spacing used for other SDK projects. This makes copy-pasting easier. Change-Id: Ibde8ecda673b2346c82aab68d4f4b49be08414ae Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
@@ -15,28 +15,14 @@ repos:
|
||||
files: .*\.(yaml|yml)$
|
||||
args: ['--unsafe']
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.14.0
|
||||
rev: v0.15.1
|
||||
hooks:
|
||||
- id: ruff-check
|
||||
args: ['--fix', '--unsafe-fixes']
|
||||
- id: ruff-format
|
||||
- repo: https://opendev.org/openstack/hacking
|
||||
rev: 7.0.0
|
||||
rev: 8.0.0
|
||||
hooks:
|
||||
- id: hacking
|
||||
additional_dependencies: []
|
||||
exclude: '^(doc|releasenotes)/.*$'
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: v1.18.2
|
||||
hooks:
|
||||
- id: mypy
|
||||
additional_dependencies:
|
||||
- types-requests
|
||||
# keep this in-sync with '[tool.mypy] exclude' in 'pyproject.toml'
|
||||
exclude: |
|
||||
(?x)(
|
||||
doc/.*
|
||||
| examples/.*
|
||||
| hacking/.*
|
||||
| releasenotes/.*
|
||||
)
|
||||
|
||||
@@ -61,7 +61,7 @@ class ListCommand(command.Lister):
|
||||
# TODO(bapalm): Fix this when cliff properly supports
|
||||
# handling the detection rather than using the hard-code below.
|
||||
if parsed_args.formatter == 'table':
|
||||
command_names = utils.format_list(command_names, "\n")
|
||||
command_names = utils.format_list(command_names, "\n") # type: ignore
|
||||
|
||||
commands.append((group, command_names))
|
||||
|
||||
|
||||
@@ -160,7 +160,9 @@ class ShowService(command.ShowOne):
|
||||
for service, service_endpoints in endpoints.items():
|
||||
if service_endpoints:
|
||||
info = {"type": service}
|
||||
info.update(service_endpoints[0])
|
||||
# FIXME(stephenfin): The return type for this in ksa is
|
||||
# wrong
|
||||
info.update(service_endpoints[0]) # type: ignore
|
||||
return zip(*sorted(info.items()))
|
||||
|
||||
msg = _(
|
||||
|
||||
@@ -466,7 +466,7 @@ class ListVolumeType(command.Lister):
|
||||
_EncryptionInfoColumn = functools.partial(
|
||||
EncryptionInfoColumn, encryption_data=encryption
|
||||
)
|
||||
formatters['id'] = _EncryptionInfoColumn
|
||||
formatters['id'] = _EncryptionInfoColumn # type: ignore
|
||||
|
||||
return (
|
||||
column_headers,
|
||||
|
||||
@@ -549,7 +549,7 @@ class ListVolumeType(command.Lister):
|
||||
_EncryptionInfoColumn = functools.partial(
|
||||
EncryptionInfoColumn, encryption_data=encryption
|
||||
)
|
||||
formatters['id'] = _EncryptionInfoColumn
|
||||
formatters['id'] = _EncryptionInfoColumn # type: ignore
|
||||
|
||||
return (
|
||||
column_headers,
|
||||
|
||||
@@ -744,15 +744,7 @@ follow_imports = "normal"
|
||||
incremental = true
|
||||
check_untyped_defs = true
|
||||
warn_unused_ignores = true
|
||||
# keep this in-sync with 'mypy.exclude' in '.pre-commit-config.yaml'
|
||||
exclude = '''
|
||||
(?x)(
|
||||
doc
|
||||
| examples
|
||||
| hacking
|
||||
| releasenotes
|
||||
)
|
||||
'''
|
||||
exclude = '(?x)(doc | examples | hacking | releasenotes)'
|
||||
|
||||
[[tool.mypy.overrides]]
|
||||
module = ["openstackclient.tests.unit.*"]
|
||||
|
||||
14
tox.ini
14
tox.ini
@@ -20,20 +20,22 @@ commands =
|
||||
[testenv:pep8]
|
||||
description =
|
||||
Run style checks.
|
||||
skip_install = true
|
||||
deps =
|
||||
pre-commit
|
||||
{[testenv:mypy]deps}
|
||||
commands =
|
||||
pre-commit run --all-files --show-diff-on-failure
|
||||
{[testenv:mypy]commands}
|
||||
|
||||
[testenv:bandit]
|
||||
[testenv:mypy]
|
||||
description =
|
||||
Run bandit security checks.
|
||||
skip_install = true
|
||||
Run type checks.
|
||||
deps =
|
||||
pre-commit
|
||||
{[testenv]deps}
|
||||
mypy
|
||||
types-requests
|
||||
commands =
|
||||
pre-commit run --all-files --show-diff-on-failure bandit
|
||||
mypy --cache-dir="{envdir}/mypy_cache" {posargs:openstackclient}
|
||||
|
||||
[testenv:unit-tips]
|
||||
commands =
|
||||
|
||||
Reference in New Issue
Block a user