-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Make mypy
behave like a proper pre-commit hook
#25313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the mypy
pre-commit hook by replacing the mypy.sh
shell script with a more robust Python script, mypy.py
. This change improves maintainability and correctly handles file lists from pre-commit
. The configuration in .pre-commit-config.yaml
is also simplified using YAML anchors. My review focuses on the new Python script, where I've found a couple of critical issues with incorrect type hints that should be addressed to ensure the script's correctness.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This pull request has merge conflicts that must be resolved before it can be |
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: charlifu <charlifu@amd.com>
mypy.sh
tomypy.py
mypy.py
takes the file list as input and will only run on those filesmypy --follow-imports skip
(no directory passed) behaves slightly differently whenpre-commit
passes all the files it would have checked implicitly based onpyproject.toml
. This is why there minor typing changes in 4 unrelated files.Example log from the first commit in this PR: