Merge "Run mypy from tox"

This commit is contained in:
Zuul
2026-02-13 19:51:32 +00:00
committed by Gerrit Code Review
7 changed files with 17 additions and 35 deletions

View File

@@ -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/.*
)

View File

@@ -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))

View File

@@ -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 = _(

View File

@@ -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,

View File

@@ -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,

View File

@@ -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
View File

@@ -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 =