From a396fcc05a45097c149276b9a66bcf766ebdf7e1 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 19 Feb 2025 20:12:33 +0000 Subject: [PATCH] pre-commit: Enable mypy Change-Id: I8ef122d9aa292758bacf349d964ef7cb5bbed288 Signed-off-by: Stephen Finucane --- .pre-commit-config.yaml | 15 +++++++++++++++ pyproject.toml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 848b3d00..8fac6070 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,3 +34,18 @@ repos: additional_dependencies: - flake8-import-order~=0.18.2 exclude: '^(doc|releasenotes|tools)/.*$' + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.13.0 + hooks: + - id: mypy + additional_dependencies: + - cliff + - keystoneauth1 + - types-requests + # keep this in-sync with '[mypy] exclude' in 'setup.cfg' + exclude: | + (?x)( + doc/.* + | examples/.* + | releasenotes/.* + ) diff --git a/pyproject.toml b/pyproject.toml index 65f01490..7e40626c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,37 @@ +[tool.mypy] +python_version = "3.9" +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 = false +warn_unused_configs = true +warn_redundant_casts = true +strict_equality = true +disallow_untyped_decorators = true +disallow_any_generics = true +# TODO(stephenfin): Change this once we've fully typed everything +disallow_subclassing_any = false +disallow_untyped_calls = false +disallow_incomplete_defs = true +disallow_untyped_defs = false +no_implicit_reexport = true +extra_checks = true +# keep this in-sync with 'mypy.exclude' in '.pre-commit-config.yaml' +exclude = ''' +(?x)( + doc + | examples + | releasenotes +) +''' + +[[tool.mypy.overrides]] +module = ["osc_lib.tests.*"] +ignore_errors = true + [tool.ruff] line-length = 79