ci: add mypy to pre-commit hooks#738
Conversation
Add the mypy static type checker to the pre-commit configuration to improve Python type safety and catch potential bugs before commit.
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe pre-commit configuration adds a pinned ChangesPre-commit type checking
Estimated code review effort: 1 (Trivial) | ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
knoepfel
left a comment
There was a problem hiding this comment.
I believe you will need to make the following change in order for pre-commit run -a to be successful on the repository:
❯ git diff
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index b35ddb56..0a399f1d 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -17,6 +17,9 @@ repos:
hooks:
- id: mypy
types_or: [python, pyi]
+ args: [--enable-incomplete-feature=NewGenericSyntax]
+ additional_dependencies:
+ - types-PyYAML
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.22
hooks:- Bump mypy from v1.11.2 to v2.3.0 - Add Python 3.12 language_version for mypy, ruff-format, and ruff hooks - Enable NewGenericSyntax feature in mypy - Add types-PyYAML as additional dependency for mypy
Good catch, thank you. |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #738 +/- ##
==========================================
- Coverage 83.84% 83.82% -0.02%
==========================================
Files 172 172
Lines 7198 7203 +5
Branches 845 845
==========================================
+ Hits 6035 6038 +3
- Misses 882 884 +2
Partials 281 281
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Add the mypy static type checker to the pre-commit configuration to
improve Python type safety and catch potential bugs before commit.
mypyv1.11.2 pre-commit hook usingpre-commit/mirrors-mypy..py) and type stub (.pyi) files before commits.