From 7914a07bdf030e901c59c11580aaeb04de053c8d Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Fri, 24 Oct 2025 10:54:07 +0300 Subject: [PATCH 1/2] Enable type-checking using mypy * Add mypy configuration file excluding errors to make mypy pass. * Add CI to run mypy --- .github/workflows/mypy.yml | 26 ++++++++++++++++++++++++++ .mypy.ini | 17 +++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 .github/workflows/mypy.yml create mode 100644 .mypy.ini diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml new file mode 100644 index 0000000000..1c1b960db9 --- /dev/null +++ b/.github/workflows/mypy.yml @@ -0,0 +1,26 @@ +name: Run mypy + +on: + push: + pull_request: + +jobs: + OSX: + runs-on: macos-latest + strategy: + matrix: + python: ["3.10", 3.14] + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v5.4.0 + with: + python-version: ${{ matrix.python }} + - name: Install mypy + run: | + pip install mypy + - name: Run mypy + run: | + mypy python + diff --git a/.mypy.ini b/.mypy.ini new file mode 100644 index 0000000000..9033030a48 --- /dev/null +++ b/.mypy.ini @@ -0,0 +1,17 @@ +[mypy] +python_version = 3.10 +warn_return_any = False +warn_unused_configs = True + +# Files to exclude +exclude = (?x)( + python/lwt_interface/cython_example/setup.py| + python/lwt_interface/setup.py| + python/setup.py + ) + +namespace_packages = False + + +# Suppressing errors +disable_error_code = assignment,attr-defined,index,empty-body,var-annotated,call-overload,syntax,union-attr,misc,import-not-found,import-untyped From 64483b12c215da5ea2d63287ce35738f76434763 Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Fri, 24 Oct 2025 11:54:47 +0300 Subject: [PATCH 2/2] add mypy to the pre-commit hook --- .pre-commit-config.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5269301e47..0241013cb8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,3 +42,11 @@ repos: args: [--skip-errors] additional_dependencies: [black==22.3.0] language_version: python3 + - repo: local + hooks: + - id: mypy + name: mypy + language: system + entry: mypy + files: \.py$ +