mypy: Enable strict mode
This is the same as what we were doing. Change-Id: Id7061bf410931001eaa8a2eb4a242fb146054d0e Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
@@ -18,13 +18,13 @@ repos:
|
|||||||
files: .*\.(yaml|yml)$
|
files: .*\.(yaml|yml)$
|
||||||
exclude: '^zuul.d/.*$'
|
exclude: '^zuul.d/.*$'
|
||||||
- repo: https://github.com/PyCQA/doc8
|
- repo: https://github.com/PyCQA/doc8
|
||||||
rev: v1.1.2
|
rev: v2.0.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: doc8
|
- id: doc8
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.11.8
|
rev: v0.12.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff-check
|
||||||
args: ['--fix', '--unsafe-fixes']
|
args: ['--fix', '--unsafe-fixes']
|
||||||
- id: ruff-format
|
- id: ruff-format
|
||||||
- repo: https://opendev.org/openstack/hacking
|
- repo: https://opendev.org/openstack/hacking
|
||||||
@@ -35,7 +35,7 @@ repos:
|
|||||||
- flake8-import-order~=0.18.2
|
- flake8-import-order~=0.18.2
|
||||||
exclude: '^(doc|releasenotes|tools)/.*$'
|
exclude: '^(doc|releasenotes|tools)/.*$'
|
||||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
rev: v1.15.0
|
rev: v1.16.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: mypy
|
- id: mypy
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
|
@@ -338,11 +338,13 @@ class BaseAPI:
|
|||||||
:returns: list of resource dicts
|
:returns: list of resource dicts
|
||||||
"""
|
"""
|
||||||
|
|
||||||
items = self.list(path)
|
resp = self.list(path)
|
||||||
if isinstance(items, dict):
|
if isinstance(resp, dict):
|
||||||
# strip off the enclosing dict
|
# strip off the enclosing dict
|
||||||
key = list(items.keys())[0]
|
key = list(resp.keys())[0]
|
||||||
items = items[key]
|
items = resp[key]
|
||||||
|
else:
|
||||||
|
items = resp
|
||||||
|
|
||||||
ret = []
|
ret = []
|
||||||
for o in items:
|
for o in items:
|
||||||
|
@@ -134,7 +134,7 @@ class OSC_Config(config.OpenStackConfig): # type: ignore
|
|||||||
default_domain = config.get('default_domain', None)
|
default_domain = config.get('default_domain', None)
|
||||||
if (
|
if (
|
||||||
identity_version == '3'
|
identity_version == '3'
|
||||||
and not auth_type.startswith('v2')
|
and (auth_type and not auth_type.startswith('v2'))
|
||||||
and default_domain
|
and default_domain
|
||||||
):
|
):
|
||||||
# NOTE(stevemar): If PROJECT_DOMAIN_ID or PROJECT_DOMAIN_NAME is
|
# NOTE(stevemar): If PROJECT_DOMAIN_ID or PROJECT_DOMAIN_NAME is
|
||||||
|
@@ -59,19 +59,22 @@ def log_level_from_string(level_string: str) -> int:
|
|||||||
|
|
||||||
def log_level_from_config(config: collections.abc.Mapping[str, ty.Any]) -> int:
|
def log_level_from_config(config: collections.abc.Mapping[str, ty.Any]) -> int:
|
||||||
# Check the command line option
|
# Check the command line option
|
||||||
verbose_level = config.get('verbose_level')
|
verbose_level_from_config = config.get('verbose_level')
|
||||||
if config.get('debug', False):
|
if config.get('debug', False):
|
||||||
verbose_level = 3
|
verbose_level_from_config = 3
|
||||||
if verbose_level == 0:
|
|
||||||
verbose_level = 'error'
|
match verbose_level_from_config:
|
||||||
elif verbose_level == 1:
|
case 0:
|
||||||
# If a command line option has not been specified, check the
|
verbose_level = 'error'
|
||||||
# configuration file
|
case 1:
|
||||||
verbose_level = config.get('log_level', 'warning')
|
# If a command line option has not been specified, check the
|
||||||
elif verbose_level == 2:
|
# configuration file
|
||||||
verbose_level = 'info'
|
verbose_level = config.get('log_level', 'warning')
|
||||||
else:
|
case 2:
|
||||||
verbose_level = 'debug'
|
verbose_level = 'info'
|
||||||
|
case _:
|
||||||
|
verbose_level = 'debug'
|
||||||
|
|
||||||
return log_level_from_string(verbose_level)
|
return log_level_from_string(verbose_level)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -39,22 +39,7 @@ packages = [
|
|||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
show_column_numbers = true
|
show_column_numbers = true
|
||||||
show_error_context = true
|
show_error_context = true
|
||||||
ignore_missing_imports = true
|
strict = true
|
||||||
follow_imports = "normal"
|
|
||||||
check_untyped_defs = true
|
|
||||||
warn_unused_ignores = true
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unused_configs = true
|
|
||||||
warn_redundant_casts = true
|
|
||||||
strict_equality = true
|
|
||||||
disallow_untyped_decorators = true
|
|
||||||
disallow_any_generics = true
|
|
||||||
disallow_subclassing_any = true
|
|
||||||
disallow_untyped_calls = true
|
|
||||||
disallow_incomplete_defs = true
|
|
||||||
disallow_untyped_defs = true
|
|
||||||
no_implicit_reexport = true
|
|
||||||
extra_checks = true
|
|
||||||
# keep this in-sync with 'mypy.exclude' in '.pre-commit-config.yaml'
|
# keep this in-sync with 'mypy.exclude' in '.pre-commit-config.yaml'
|
||||||
exclude = '''
|
exclude = '''
|
||||||
(?x)(
|
(?x)(
|
||||||
|
Reference in New Issue
Block a user