From ef0df7dbd68fcd47391e3b45b94378c2a21b59c2 Mon Sep 17 00:00:00 2001
From: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Date: Fri, 5 Jun 2026 15:56:27 +0100
Subject: [PATCH] [CI] Bump mypy version `1.19.1` -> `1.20.2` (#44647)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
---
.github/mergify.yml | 12 -----------
.pre-commit-config.yaml | 20 +++++++------------
AGENTS.md | 2 +-
docs/contributing/README.md | 2 +-
tests/compile/test_graph_partition.py | 2 ++
tests/models/language/pooling/test_colbert.py | 2 +-
tools/pre_commit/mypy.py | 8 +++-----
.../fused_moe/experts/trtllm_mxint4_moe.py | 2 ++
.../model_executor/model_loader/tensorizer.py | 2 +-
9 files changed, 18 insertions(+), 34 deletions(-)
diff --git a/.github/mergify.yml b/.github/mergify.yml
index 6caec515d32..a5d4e609474 100644
--- a/.github/mergify.yml
+++ b/.github/mergify.yml
@@ -36,18 +36,6 @@ pull_request_rules:
For future commits, `pre-commit` will run automatically on changed files before each commit.
- > [!TIP]
- >
- > Is mypy failing?
- >
- > mypy is run differently in CI. If the failure is related to this check, please use the following command to run it locally:
- >
- > ```bash
- > # For mypy (substitute "3.10" with the failing version if needed)
- > pre-commit run --hook-stage manual mypy-3.10
- > ```
- >
-
- name: comment-dco-failure
description: Comment on PR when DCO check fails
conditions:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index c11a80683f8..dff099e3697 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -148,33 +148,27 @@ repos:
language: python
entry: python tools/pre_commit/generate_nightly_torch_test.py
files: ^requirements/test/cuda\.(in|txt)$
- - id: mypy-local
- name: Run mypy locally for lowest supported Python version
- entry: python tools/pre_commit/mypy.py 0 "3.10"
- stages: [pre-commit] # Don't run in CI
+ - id: mypy-3.10 # TODO: Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward
+ name: Run mypy for Python 3.10
+ entry: python tools/pre_commit/mypy.py "3.10"
<<: &mypy_common
language: python
types_or: [python, pyi]
require_serial: true
- additional_dependencies: ["mypy[faster-cache]==1.19.1", regex, types-cachetools, types-setuptools, types-PyYAML, types-requests, types-torch, pydantic]
- - id: mypy-3.10 # TODO: Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward
- name: Run mypy for Python 3.10
- entry: python tools/pre_commit/mypy.py 1 "3.10"
- <<: *mypy_common
- stages: [manual] # Only run in CI
+ additional_dependencies: ["mypy==1.20.2", regex, types-cachetools, types-setuptools, types-PyYAML, types-requests, types-torch, pydantic]
- id: mypy-3.11 # TODO: Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward
name: Run mypy for Python 3.11
- entry: python tools/pre_commit/mypy.py 1 "3.11"
+ entry: python tools/pre_commit/mypy.py "3.11"
<<: *mypy_common
stages: [manual] # Only run in CI
- id: mypy-3.12 # TODO: Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward
name: Run mypy for Python 3.12
- entry: python tools/pre_commit/mypy.py 1 "3.12"
+ entry: python tools/pre_commit/mypy.py "3.12"
<<: *mypy_common
stages: [manual] # Only run in CI
- id: mypy-3.13 # TODO: Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward
name: Run mypy for Python 3.13
- entry: python tools/pre_commit/mypy.py 1 "3.13"
+ entry: python tools/pre_commit/mypy.py "3.13"
<<: *mypy_common
stages: [manual] # Only run in CI
- id: shellcheck
diff --git a/AGENTS.md b/AGENTS.md
index 6c9ca6377a0..441b8d9fb73 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -98,7 +98,7 @@ pre-commit run --all-files
pre-commit run ruff-check --all-files
# Run mypy as it is in CI:
-pre-commit run mypy-3.10 --all-files --hook-stage manual
+pre-commit run mypy-3.12 --all-files --hook-stage manual
```
The line length limit for Python code is 88 characters. If you are not sure, use pre-commit to check.
diff --git a/docs/contributing/README.md b/docs/contributing/README.md
index 9b5e26d0fed..3fc8b6dd52b 100644
--- a/docs/contributing/README.md
+++ b/docs/contributing/README.md
@@ -101,7 +101,7 @@ vLLM's `pre-commit` hooks will now run automatically every time you commit.
Some `pre-commit` hooks only run in CI. If you need to, you can run them locally with:
```bash
- pre-commit run --hook-stage manual mypy-3.10
+ pre-commit run --hook-stage manual mypy-3.11
```
### Documentation
diff --git a/tests/compile/test_graph_partition.py b/tests/compile/test_graph_partition.py
index 4cb199b5897..8e20b704fac 100644
--- a/tests/compile/test_graph_partition.py
+++ b/tests/compile/test_graph_partition.py
@@ -565,6 +565,8 @@ def test_size_used_in_multiple_consumer_subgraphs():
torch._dynamo.mark_dynamic(x, 0)
torch._dynamo.mark_dynamic(y, 0)
torch.compile(model_fn, backend=capturing_backend)(x, y)
+ assert captured_graph is not None, "Graph should be captured by backend"
+ assert captured_inputs is not None, "Example inputs should be captured by backend"
split_gm, split_items = split_graph(captured_graph, ["aten::sigmoid"])
diff --git a/tests/models/language/pooling/test_colbert.py b/tests/models/language/pooling/test_colbert.py
index 10c229fe063..b6ff9b9ffbd 100644
--- a/tests/models/language/pooling/test_colbert.py
+++ b/tests/models/language/pooling/test_colbert.py
@@ -14,7 +14,7 @@ from vllm.entrypoints.pooling.scoring.utils import compute_maxsim_score
# -----------------------------------------------------------------------
# Model definitions: (model_name, colbert_dim, extra vllm_runner kwargs)
# -----------------------------------------------------------------------
-COLBERT_MODELS = {
+COLBERT_MODELS: dict[str, dict] = {
"bert": {
"model": "answerdotai/answerai-colbert-small-v1",
"colbert_dim": 96,
diff --git a/tools/pre_commit/mypy.py b/tools/pre_commit/mypy.py
index 22855080824..a174208da4c 100755
--- a/tools/pre_commit/mypy.py
+++ b/tools/pre_commit/mypy.py
@@ -8,11 +8,9 @@ on files that have been changed. It groups files into different mypy calls
based on their directory to avoid import following issues.
Usage:
- python tools/pre_commit/mypy.py
+ python tools/pre_commit/mypy.py
Args:
- ci: "1" if running in CI, "0" otherwise. In CI, follow_imports is set to
- "silent" for the main group of files.
python_version: Python version to use (e.g., "3.10") or "local" to use
the local Python version.
changed_files: List of changed files to check.
@@ -98,8 +96,8 @@ def mypy(
def main():
- python_version = sys.argv[2]
- file_groups = group_files(sys.argv[3:])
+ python_version = sys.argv[1]
+ file_groups = group_files(sys.argv[2:])
if python_version == "local":
python_version = f"{sys.version_info.major}.{sys.version_info.minor}"
diff --git a/vllm/model_executor/layers/fused_moe/experts/trtllm_mxint4_moe.py b/vllm/model_executor/layers/fused_moe/experts/trtllm_mxint4_moe.py
index a65873aca49..a412a6936d3 100644
--- a/vllm/model_executor/layers/fused_moe/experts/trtllm_mxint4_moe.py
+++ b/vllm/model_executor/layers/fused_moe/experts/trtllm_mxint4_moe.py
@@ -30,6 +30,8 @@ class TrtLlmMxint4ExpertsMonolithic(mk.FusedMoEExpertsMonolithic):
self,
moe_config: FusedMoEConfig,
quant_config: FusedMoEQuantConfig,
+ max_num_tokens: int | None = None,
+ num_dispatchers: int | None = None,
):
super().__init__(moe_config, quant_config)
self.topk = moe_config.experts_per_token
diff --git a/vllm/model_executor/model_loader/tensorizer.py b/vllm/model_executor/model_loader/tensorizer.py
index 736b2134604..008abb6fdfe 100644
--- a/vllm/model_executor/model_loader/tensorizer.py
+++ b/vllm/model_executor/model_loader/tensorizer.py
@@ -687,7 +687,7 @@ def serialize_vllm_model(
serializer = TensorSerializer(
stream,
encryption=encryption_params,
- **tensorizer_config.serialization_kwargs,
+ **(tensorizer_config.serialization_kwargs or {}),
)
serializer.write_module(model)
serializer.close()