[CI] Enable mypy import following for vllm/compilation (#33199)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Harry Mellor
2026-01-28 08:59:54 +00:00
committed by GitHub
parent 9581185d51
commit f1acbd68c5
5 changed files with 4 additions and 53 deletions

View File

@@ -26,6 +26,7 @@ import regex as re
FILES = [
"vllm/*.py",
"vllm/assets",
"vllm/compilation",
"vllm/distributed",
"vllm/engine",
"vllm/entrypoints",
@@ -58,7 +59,6 @@ FILES = [
SEPARATE_GROUPS = [
"tests",
# v0 related
"vllm/compilation",
"vllm/lora",
"vllm/model_executor",
# v1 related
@@ -76,11 +76,6 @@ EXCLUDE = [
"vllm/v1/attention/ops",
]
# Directories that should be checked with --strict
STRICT_DIRS = [
"vllm/compilation",
]
def group_files(changed_files: list[str]) -> dict[str, list[str]]:
"""
@@ -112,17 +107,11 @@ def group_files(changed_files: list[str]) -> dict[str, list[str]]:
return file_groups
def is_strict_file(filepath: str) -> bool:
"""Check if a file should be checked with strict mode."""
return any(filepath.startswith(strict_dir) for strict_dir in STRICT_DIRS)
def mypy(
targets: list[str],
python_version: str | None,
follow_imports: str | None,
file_group: str,
strict: bool = False,
) -> int:
"""
Run mypy on the given targets.
@@ -134,7 +123,6 @@ def mypy(
follow_imports: Value for the --follow-imports option or None to use
the default mypy behavior.
file_group: The file group name for logging purposes.
strict: If True, run mypy with --strict flag.
Returns:
The return code from mypy.
@@ -144,8 +132,6 @@ def mypy(
args += ["--python-version", python_version]
if follow_imports is not None:
args += ["--follow-imports", follow_imports]
if strict:
args += ["--strict"]
print(f"$ {' '.join(args)} {file_group}")
return subprocess.run(args + targets, check=False).returncode
@@ -162,29 +148,9 @@ def main():
for file_group, changed_files in file_groups.items():
follow_imports = None if ci and file_group == "" else "skip"
if changed_files:
# Separate files into strict and non-strict groups
strict_files = [f for f in changed_files if is_strict_file(f)]
non_strict_files = [f for f in changed_files if not is_strict_file(f)]
# Run mypy on non-strict files
if non_strict_files:
returncode |= mypy(
non_strict_files,
python_version,
follow_imports,
file_group,
strict=False,
)
# Run mypy on strict files with --strict flag
if strict_files:
returncode |= mypy(
strict_files,
python_version,
follow_imports,
f"{file_group} (strict)",
strict=True,
)
returncode |= mypy(
changed_files, python_version, follow_imports, file_group
)
return returncode