Skip to content

Commit 2b582be

Browse files
authored
Enable mypy type checking in pre-commit hooks (#89)
This PR enables mypy type checking in the pre-commit hooks configuration. ## Changes - Add mypy hook using the mirrors version for CI compatibility - Include all necessary dependencies for proper type checking - Configure mypy to run on `src/` directory only - Use `pass_filenames: false` to avoid module resolution issues ## Benefits - **Type safety**: Catch type-related bugs before they reach the main branch - **CI integration**: Works seamlessly in GitHub Actions and other CI environments - **Developer experience**: Automatic type checking on every commit - **Code quality**: Maintains strict typing standards established in `pyproject.toml` ## Technical Details - Uses `repo: https://github.com/pre-commit/mirrors-mypy` for CI compatibility - Includes comprehensive `additional_dependencies` list for all project imports - Configured with `args: [src/]` and `pass_filenames: false` to handle package structure correctly - Runs mypy v1.18.1 with strict type checking settings from `pyproject.toml` ## Testing - ✅ All 138 source files in `src/` pass mypy type checking - ✅ All pre-commit hooks work together successfully - ✅ Configuration tested locally and ready for CI The test files in `tests/` have 126+ type issues that would require significant refactoring, so they are excluded for now but could be addressed in a future PR.
1 parent 65c3867 commit 2b582be

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

.pre-commit-config.yaml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,23 @@ repos:
2323
- id: prettier
2424
types_or: [markdown, yaml]
2525
exclude: ^snapshots/.*/show/
26-
# MyPy type checking (run manually with: mypy src/)
27-
# Disabled in pre-commit due to module resolution issues in isolated environment
28-
# - repo: https://github.com/pre-commit/mirrors-mypy
29-
# rev: v1.8.0
30-
# hooks:
31-
# - id: mypy
32-
# additional_dependencies: [pybatfish, attrs, pyparsing, pandas-stubs, types-requests]
33-
# args: [--explicit-package-bases, --namespace-packages]
34-
# files: ^src/
26+
- repo: https://github.com/pre-commit/mirrors-mypy
27+
rev: v1.18.1
28+
hooks:
29+
- id: mypy
30+
additional_dependencies:
31+
[
32+
pybatfish,
33+
attrs,
34+
pyparsing,
35+
pandas-stubs,
36+
types-requests,
37+
PyYAML,
38+
requests,
39+
pandas,
40+
pytest,
41+
types-PyYAML,
42+
]
43+
args: [src/]
44+
pass_filenames: false
45+
files: ^src/.*\.py$

0 commit comments

Comments
 (0)