From ec4fd81c1121acbd333f5a169f3f59e73946a3be Mon Sep 17 00:00:00 2001
From: Stephen Finucane <stephenfin@redhat.com>
Date: Wed, 19 Feb 2025 20:15:44 +0000
Subject: [PATCH] pre-commit: Enable mypy

To ease migration of various commands from OSC to SDK.

Change-Id: I4645237e8808239e4d605f7f45138449c9439949
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
---
 .pre-commit-config.yaml | 13 +++++++++++++
 pyproject.toml          | 22 ++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 14bfc2b85f..a8382cf11b 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -26,3 +26,16 @@ repos:
       - id: hacking
         additional_dependencies: []
         exclude: '^(doc|releasenotes)/.*$'
+  - repo: https://github.com/pre-commit/mirrors-mypy
+    rev: v1.15.0
+    hooks:
+      - id: mypy
+        additional_dependencies:
+          - 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 9a30d5bc50..2a532cef68 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,3 +1,25 @@
+[tool.mypy]
+python_version = "3.9"
+show_column_numbers = true
+show_error_context = true
+ignore_missing_imports = true
+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
+    | releasenotes
+  )
+'''
+
+[[tool.mypy.overrides]]
+module = ["openstackclient.tests.unit.*"]
+ignore_errors = true
+
 [tool.ruff]
 line-length = 79