diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 420342b..4f79752 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,24 +13,14 @@ repos: - id: check-yaml files: .*\.(yaml|yml)$ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.13.0 + rev: v0.14.8 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.17.1 - hooks: - - id: mypy - exclude: | - (?x)( - oslo_context/fixture.py - | doc/.* - | releasenotes/.* - ) diff --git a/pyproject.toml b/pyproject.toml index b5f81ab..e7af979 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,20 @@ packages = [ "oslo_context" ] +[tool.mypy] +python_version = "3.10" +show_column_numbers = true +show_error_context = true +strict = true +ignore_missing_imports = true +exclude = '(?x)(doc | releasenotes)' + +[[tool.mypy.overrides]] +module = ["oslo_context.tests.*"] +disallow_untyped_calls = false +disallow_untyped_defs = false +disallow_subclassing_any = false + [tool.ruff] line-length = 79 @@ -49,43 +63,3 @@ select = ["E4", "E7", "E9", "F", "S", "UP"] [tool.ruff.lint.per-file-ignores] "oslo_context/tests/*" = ["S"] - -[tool.mypy] -python_version = "3.10" -show_column_numbers = true -show_error_context = true -ignore_missing_imports = true -follow_imports = "normal" -check_untyped_defs = true -warn_unused_ignores = false -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' -exclude = ''' -(?x)( - doc - | releasenotes - ) -''' - -[[tool.mypy.overrides]] -module = [ - "oslo_context.fixture", - "oslo_context.tests.*", -] -warn_return_any = false -disallow_untyped_decorators = false -disallow_any_generics = false -disallow_subclassing_any = false -disallow_untyped_calls = false -disallow_untyped_defs = false diff --git a/tox.ini b/tox.ini index c20c196..9ca03b7 100644 --- a/tox.ini +++ b/tox.ini @@ -9,13 +9,23 @@ deps = commands = stestr run --slowest {posargs} [testenv:pep8] -skip_install = true description = - Run linters. + Run style checks. deps = pre-commit + {[testenv:mypy]deps} commands = pre-commit run -a + {[testenv:mypy]commands} + +[testenv:mypy] +description = + Run type checks. +deps = + {[testenv]deps} + mypy +commands = + mypy --cache-dir="{envdir}/mypy_cache" {posargs:oslo_context} [testenv:venv] commands = {posargs}