From e246ad6f0cbc4706b5d2f4ad893fbe78409c5366 Mon Sep 17 00:00:00 2001 From: Harry Mellor <19981378+hmellor@users.noreply.github.com> Date: Thu, 9 Oct 2025 14:02:40 +0100 Subject: [PATCH] Upgrade Pydantic to v2.12.0 and remove hack for Python 3.13 (#26481) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> --- requirements/common.txt | 2 +- requirements/nightly_torch_test.txt | 2 +- requirements/test.in | 2 +- requirements/test.txt | 8 ++++---- vllm/config/utils.py | 12 +----------- 5 files changed, 8 insertions(+), 18 deletions(-) diff --git a/requirements/common.txt b/requirements/common.txt index a52745f698703..a87e77dc9901d 100644 --- a/requirements/common.txt +++ b/requirements/common.txt @@ -13,7 +13,7 @@ protobuf # Required by LlamaTokenizer. fastapi[standard] >= 0.115.0 # Required by FastAPI's form models in the OpenAI API server's audio transcriptions endpoint. aiohttp openai >= 1.99.1 # For Responses API with reasoning content -pydantic >= 2.11.7 +pydantic >= 2.12.0 prometheus_client >= 0.18.0 pillow # Required for image processing prometheus-fastapi-instrumentator >= 7.0.0 diff --git a/requirements/nightly_torch_test.txt b/requirements/nightly_torch_test.txt index dc1a9c0263966..52b5d269db30c 100644 --- a/requirements/nightly_torch_test.txt +++ b/requirements/nightly_torch_test.txt @@ -44,4 +44,4 @@ numba == 0.61.2 # Required for N-gram speculative decoding numpy runai-model-streamer[s3,gcs]==0.14.0 fastsafetensors>=0.1.10 -pydantic>=2.10 # 2.9 leads to error on python 3.10 +pydantic>=2.12 # 2.11 leads to error on python 3.13 diff --git a/requirements/test.in b/requirements/test.in index 85e3d29d94d1d..bf69628e67b2d 100644 --- a/requirements/test.in +++ b/requirements/test.in @@ -52,7 +52,7 @@ numba == 0.61.2 # Required for N-gram speculative decoding numpy runai-model-streamer[s3,gcs]==0.14.0 fastsafetensors>=0.1.10 -pydantic>=2.10 # 2.9 leads to error on python 3.10 +pydantic>=2.12 # 2.11 leads to error on python 3.13 decord==0.6.0 terratorch @ git+https://github.com/IBM/terratorch.git@1.1.rc3 # required for PrithviMAE test gpt-oss >= 0.0.7; python_version > '3.11' \ No newline at end of file diff --git a/requirements/test.txt b/requirements/test.txt index 795fa1b7ad083..75d3d40f61346 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -783,7 +783,7 @@ pycparser==2.22 # via cffi pycryptodomex==3.22.0 # via blobfile -pydantic==2.11.7 +pydantic==2.12.0 # via # -r requirements/test.in # albumentations @@ -797,7 +797,7 @@ pydantic==2.11.7 # openai-harmony # pydantic-extra-types # ray -pydantic-core==2.33.2 +pydantic-core==2.41.1 # via pydantic pydantic-extra-types==2.10.5 # via mistral-common @@ -1224,7 +1224,7 @@ types-python-dateutil==2.9.0.20241206 # via arrow typeshed-client==2.8.2 # via jsonargparse -typing-extensions==4.12.2 +typing-extensions==4.15.0 # via # aiosignal # albumentations @@ -1253,7 +1253,7 @@ typing-extensions==4.12.2 # typer # typeshed-client # typing-inspection -typing-inspection==0.4.1 +typing-inspection==0.4.2 # via pydantic tzdata==2024.2 # via pandas diff --git a/vllm/config/utils.py b/vllm/config/utils.py index f0b18a699f46c..5e7e7580c5a9e 100644 --- a/vllm/config/utils.py +++ b/vllm/config/utils.py @@ -111,17 +111,7 @@ def get_attr_docs(cls: type[Any]) -> dict[str, str]: https://davidism.com/mit-license/ """ - try: - cls_node = ast.parse(textwrap.dedent(inspect.getsource(cls))).body[0] - except (OSError, KeyError, TypeError): - # HACK: Python 3.13+ workaround - set missing __firstlineno__ - # Workaround can be removed after we upgrade to pydantic==2.12.0 - with open(inspect.getfile(cls)) as f: - for i, line in enumerate(f): - if f"class {cls.__name__}" in line and ":" in line: - cls.__firstlineno__ = i + 1 - break - cls_node = ast.parse(textwrap.dedent(inspect.getsource(cls))).body[0] + cls_node = ast.parse(textwrap.dedent(inspect.getsource(cls))).body[0] if not isinstance(cls_node, ast.ClassDef): raise TypeError("Given object was not a class.")