Skip to content
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

[CI] Pass local python version explicitly to pre-commit mypy.sh #12224

Merged
merged 3 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ repos:
hooks:
- id: mypy-local
name: Run mypy for local Python installation
entry: tools/mypy.sh
entry: tools/mypy.sh 1 "local"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
entry: tools/mypy.sh 1 "local"
entry: tools/mypy.sh 0 "local"

Should be 0 here to indicate not running in CI

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. But why does here use CI=1?

name: Run mypy for Python 3.9
entry: tools/mypy.sh 1 "3.9"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version-locked steps are intended to be run in CI only.

language: python
types: [python]
additional_dependencies: &mypy_deps [mypy==1.11.1, types-setuptools, types-PyYAML, types-requests]
Expand Down
4 changes: 4 additions & 0 deletions tools/mypy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ if [ "$CI" -eq 1 ]; then
set -e
fi

if [ $PYTHON_VERSION == "local" ]; then
DarkLight1337 marked this conversation as resolved.
Show resolved Hide resolved
PYTHON_VERSION=$(python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
fi

run_mypy() {
echo "Running mypy on $1"
if [ "$CI" -eq 1 ] && [ -z "$1" ]; then
Expand Down
Loading