[MyPy][1/N] Fix mypy errors in some tests/ directories and enforce follow-imports=silent (#49570)
Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com> Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
co-authored by
Harry Mellor
parent
89d97d9a16
commit
38a267cdd5
+41
-24
@@ -21,34 +21,55 @@ import sys
|
||||
|
||||
import regex as re
|
||||
|
||||
# Paths verified clean under follow_imports="silent". Matched before
|
||||
# SEPARATE_GROUPS, so these files join the default group and are checked at the
|
||||
# stricter setting even while a parent directory remains in SEPARATE_GROUPS.
|
||||
#
|
||||
# Fixing a directory means moving it from SEPARATE_GROUPS to here. Without that
|
||||
# move the fixes are not enforced because "tests" claims every file below it.
|
||||
SILENT_GROUPS = [
|
||||
"tests/compile/correctness_e2e",
|
||||
"tests/compile/fullgraph",
|
||||
"tests/compile/fusions_e2e",
|
||||
"tests/config",
|
||||
"tests/entrypoints/generate",
|
||||
"tests/entrypoints/tool_parsers",
|
||||
"tests/entrypoints/weight_transfer",
|
||||
"tests/kernels/core",
|
||||
"tests/kernels/mamba",
|
||||
"tests/models/language",
|
||||
"tests/models/quantization",
|
||||
"tests/plugins/bge_m3_sparse_plugin",
|
||||
"tests/plugins/prithvi_io_processor_plugin",
|
||||
"tests/plugins/vllm_add_dummy_platform",
|
||||
"tests/plugins/vllm_add_dummy_stat_logger",
|
||||
"tests/plugins_tests/gguf",
|
||||
"tests/plugins_tests/lora_resolvers",
|
||||
"tests/spec_decode",
|
||||
"tests/transformers_utils",
|
||||
"tests/v1/distributed",
|
||||
"tests/v1/shutdown",
|
||||
]
|
||||
|
||||
# After fixing errors resulting from changing follow_imports
|
||||
# from "skip" to "silent", remove its directory from SEPARATE_GROUPS.
|
||||
# from "skip" to "silent", move its directory to SILENT_GROUPS.
|
||||
SEPARATE_GROUPS = [
|
||||
"tests",
|
||||
"tests/benchmarks",
|
||||
"tests/compile/correctness_e2e",
|
||||
"tests/config",
|
||||
"tests/compile",
|
||||
"tests/compile/fullgraph",
|
||||
"tests/compile/fusions_e2e",
|
||||
"tests/compile/passes",
|
||||
"tests/distributed",
|
||||
"tests/entrypoints/anthropic",
|
||||
"tests/entrypoints/generate",
|
||||
"tests/entrypoints/llm",
|
||||
"tests/entrypoints/multimodal",
|
||||
"tests/entrypoints/openai",
|
||||
"tests/entrypoints/pooling",
|
||||
"tests/entrypoints/serve",
|
||||
"tests/entrypoints/speech_to_text",
|
||||
"tests/entrypoints/tool_parsers",
|
||||
"tests/entrypoints/unit_tests",
|
||||
"tests/entrypoints/weight_transfer",
|
||||
"tests/kernels",
|
||||
"tests/kernels/attention",
|
||||
"tests/kernels/core",
|
||||
"tests/kernels/helion",
|
||||
"tests/kernels/mamba",
|
||||
"tests/kernels/moe",
|
||||
"tests/kernels/quantization",
|
||||
"tests/lora",
|
||||
@@ -57,34 +78,23 @@ SEPARATE_GROUPS = [
|
||||
"tests/model_executor/model_loader",
|
||||
"tests/models",
|
||||
"tests/models/test_initialization.py",
|
||||
"tests/models/language",
|
||||
"tests/models/multimodal",
|
||||
"tests/models/quantization",
|
||||
"tests/multimodal",
|
||||
"tests/parser",
|
||||
"tests/plugins_tests/gguf",
|
||||
"tests/plugins_tests/lora_resolvers",
|
||||
"tests/plugins/bge_m3_sparse_plugin",
|
||||
"tests/plugins/prithvi_io_processor_plugin",
|
||||
"tests/plugins/vllm_add_dummy_platform",
|
||||
"tests/plugins/vllm_add_dummy_stat_logger",
|
||||
"tests/plugins_tests",
|
||||
"tests/quantization",
|
||||
"tests/reasoning",
|
||||
"tests/renderers",
|
||||
"tests/samplers",
|
||||
"tests/spec_decode",
|
||||
"tests/tokenizers_",
|
||||
"tests/tool_parsers",
|
||||
"tests/tool_use",
|
||||
"tests/transformers_utils",
|
||||
"tests/utils_",
|
||||
"tests/v1",
|
||||
"tests/v1/attention",
|
||||
"tests/v1/core",
|
||||
"tests/v1/cudagraph",
|
||||
"tests/v1/determinism",
|
||||
"tests/v1/distributed",
|
||||
"tests/v1/e2e",
|
||||
"tests/v1/ec_connector",
|
||||
"tests/v1/engine",
|
||||
@@ -94,7 +104,6 @@ SEPARATE_GROUPS = [
|
||||
"tests/v1/logits_processors",
|
||||
"tests/v1/metrics",
|
||||
"tests/v1/sample",
|
||||
"tests/v1/shutdown",
|
||||
"tests/v1/simple_kv_offload",
|
||||
"tests/v1/spec_decode",
|
||||
"tests/v1/streaming_input",
|
||||
@@ -142,14 +151,22 @@ def group_files(changed_files: list[str]) -> dict[str, list[str]]:
|
||||
A dictionary mapping file group names to lists of changed files.
|
||||
"""
|
||||
exclude_pattern = re.compile(f"^{'|'.join(EXCLUDE)}.*")
|
||||
file_groups = {"": []}
|
||||
silent_pattern = re.compile(f"^({'|'.join(SILENT_GROUPS)}).*")
|
||||
file_groups: dict[str, list[str]] = {"": []}
|
||||
file_groups.update({k: [] for k in SEPARATE_GROUPS})
|
||||
# Longest path first so a sub-directory is not shadowed by its parent
|
||||
separate_groups = sorted(SEPARATE_GROUPS, key=len, reverse=True)
|
||||
for changed_file in changed_files:
|
||||
# Skip files which should be ignored completely
|
||||
if exclude_pattern.match(changed_file):
|
||||
continue
|
||||
# Already-fixed paths go in the default group, which runs at the
|
||||
# stricter follow_imports setting from pyproject.toml
|
||||
if silent_pattern.match(changed_file):
|
||||
file_groups[""].append(changed_file)
|
||||
continue
|
||||
# Group files by mypy call
|
||||
for directory in SEPARATE_GROUPS:
|
||||
for directory in separate_groups:
|
||||
if re.match(f"^{directory}.*", changed_file):
|
||||
file_groups[directory].append(changed_file)
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user