Skip to content

[Feature]: Fix all of the mypy check #26533

@yewentao256

Description

@yewentao256

🚀 The feature, motivation and pitch

Thanks for the context from @hmellor !

A following up issue for #26448

Now in vllm-source/tools/pre_commit/mypy.py, several directories are checked with mypy in isolation with import following skipped:

SEPARATE_GROUPS = [
    "tests",
    # v0 related
    "vllm/attention",
    "vllm/compilation",
    "vllm/engine",
    "vllm/inputs",
    "vllm/lora",
    "vllm/model_executor",
    "vllm/plugins",
    "vllm/worker",
    # v1 related
    "vllm/v1/attention",
    "vllm/v1/executor",
    "vllm/v1/kv_offload",
    "vllm/v1/metrics",
    "vllm/v1/pool",
    "vllm/v1/sample",
    "vllm/v1/spec_decode",
    "vllm/v1/structured_output",
]

V0 related is not that important since we will deprecate all of them soon, but v1 is strongly needed.

This won't break pre-commit CI because all the files in each directory are checked, so no imports need following. However, if you only edit one file locally, the pre-commit check will only run on that file and the imports will not be followed. This may cause the pre-commit check to fail locally.

We can gradually fix all of the SEPARATE_GROUPS to FILES to solve the issue throughly

Instructions

Move code like "vllm/v1/executor" from SEPARATE_GROUPS to FILES

diff --git a/tools/pre_commit/mypy.py b/tools/pre_commit/mypy.py
index 8d04848f8..68d8214ad 100755
--- a/tools/pre_commit/mypy.py
+++ b/tools/pre_commit/mypy.py
@@ -38,6 +38,8 @@ FILES = [
     "vllm/usage",
     "vllm/v1/core",
     "vllm/v1/engine",
+    "vllm/v1/attention",
+    "vllm/v1/executor",
 ]
 
 # After fixing errors resulting from changing follow_imports
@@ -54,8 +56,7 @@ SEPARATE_GROUPS = [
     "vllm/plugins",
     "vllm/worker",
     # v1 related
-    "vllm/v1/attention",
-    "vllm/v1/executor",
+
     "vllm/v1/kv_offload",
     "vllm/v1/metrics",
     "vllm/v1/pool",

Then run the command pre-commit run --hook-stage manual mypy-3.13 -a, you will see a lot of errors, and fix the error locally.


Pull requests:

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions