Skip to content

Commit

Permalink
[CI/Build] Improve mypy + python version matrix
Browse files Browse the repository at this point in the history
The `mypy` CI job ran using multiple Python versions, though it was
always checking for compatibility with Python 3.9 because of the
config option in `pyproject.toml`.

This change makes it so local usage of `format.sh` will still default
to checking for compatibility with the lowest Python version (3.9).
The CI job will now check for compatibility with each python version
used in the matrix instead of only running `mypy` itself with
different versions, but always checking 3.9 compatibility.

Signed-off-by: Russell Bryant <[email protected]>
  • Loading branch information
russellb committed Nov 6, 2024
1 parent a5bba7d commit b773dc1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mypy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:
- name: Mypy
run: |
echo "::add-matcher::.github/workflows/matchers/mypy.json"
tools/mypy.sh 1
tools/mypy.sh 1 ${{ matrix.python-version }}
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,12 @@ ignore = [
]

[tool.mypy]
python_version = "3.9"

ignore_missing_imports = true
check_untyped_defs = true
follow_imports = "silent"

# After fixing type errors resulting from follow_imports: "skip" -> "silent",
# move the directory here and remove it from format.sh and mypy.yaml
# move the directory here and remove it from tools/mypy.sh
files = [
"vllm/*.py",
"vllm/adapter_commons",
Expand Down
5 changes: 3 additions & 2 deletions tools/mypy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

CI=${1:-0}
PYTHON_VERSION=${2:-3.9}

if [ $CI -eq 1 ]; then
set -e
Expand All @@ -9,10 +10,10 @@ fi
run_mypy() {
echo "Running mypy on $1"
if [ $CI -eq 1 ] && [ -z "$1" ]; then
mypy "$@"
mypy --python-version "${PYTHON_VERSION}" "$@"
return
fi
mypy --follow-imports skip "$@"
mypy --follow-imports skip --python-version "${PYTHON_VERSION}" "$@"
}

run_mypy # Note that this is less strict than CI
Expand Down

0 comments on commit b773dc1

Please sign in to comment.