diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c2e5fe4c..e596c7fb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,13 +18,13 @@ repos: files: .*\.(yaml|yml)$ exclude: '^zuul.d/.*$' - repo: https://github.com/PyCQA/doc8 - rev: v1.1.2 + rev: v2.0.0 hooks: - id: doc8 - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.8 + rev: v0.12.1 hooks: - - id: ruff + - id: ruff-check args: ['--fix', '--unsafe-fixes'] - id: ruff-format - repo: https://opendev.org/openstack/hacking @@ -35,7 +35,7 @@ repos: - flake8-import-order~=0.18.2 exclude: '^(doc|releasenotes|tools)/.*$' - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.15.0 + rev: v1.16.1 hooks: - id: mypy additional_dependencies: diff --git a/osc_lib/api/api.py b/osc_lib/api/api.py index 624d6a32..a1dbc025 100644 --- a/osc_lib/api/api.py +++ b/osc_lib/api/api.py @@ -338,11 +338,13 @@ class BaseAPI: :returns: list of resource dicts """ - items = self.list(path) - if isinstance(items, dict): + resp = self.list(path) + if isinstance(resp, dict): # strip off the enclosing dict - key = list(items.keys())[0] - items = items[key] + key = list(resp.keys())[0] + items = resp[key] + else: + items = resp ret = [] for o in items: diff --git a/osc_lib/cli/client_config.py b/osc_lib/cli/client_config.py index 69b7db37..b592f3a4 100644 --- a/osc_lib/cli/client_config.py +++ b/osc_lib/cli/client_config.py @@ -134,7 +134,7 @@ class OSC_Config(config.OpenStackConfig): # type: ignore default_domain = config.get('default_domain', None) if ( identity_version == '3' - and not auth_type.startswith('v2') + and (auth_type and not auth_type.startswith('v2')) and default_domain ): # NOTE(stevemar): If PROJECT_DOMAIN_ID or PROJECT_DOMAIN_NAME is diff --git a/osc_lib/logs.py b/osc_lib/logs.py index 9746144a..26831527 100644 --- a/osc_lib/logs.py +++ b/osc_lib/logs.py @@ -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: # Check the command line option - verbose_level = config.get('verbose_level') + verbose_level_from_config = config.get('verbose_level') if config.get('debug', False): - verbose_level = 3 - if verbose_level == 0: - verbose_level = 'error' - elif verbose_level == 1: - # If a command line option has not been specified, check the - # configuration file - verbose_level = config.get('log_level', 'warning') - elif verbose_level == 2: - verbose_level = 'info' - else: - verbose_level = 'debug' + verbose_level_from_config = 3 + + match verbose_level_from_config: + case 0: + verbose_level = 'error' + case 1: + # If a command line option has not been specified, check the + # configuration file + verbose_level = config.get('log_level', 'warning') + case 2: + verbose_level = 'info' + case _: + verbose_level = 'debug' + return log_level_from_string(verbose_level) diff --git a/pyproject.toml b/pyproject.toml index 54bac773..2bb8883e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,22 +39,7 @@ packages = [ [tool.mypy] show_column_numbers = true show_error_context = true -ignore_missing_imports = 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 +strict = true # keep this in-sync with 'mypy.exclude' in '.pre-commit-config.yaml' exclude = ''' (?x)(