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>
This commit is contained in:
Harry Mellor 2025-10-09 14:02:40 +01:00 committed by GitHub
parent 5728da11ea
commit e246ad6f0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 8 additions and 18 deletions

View File

@ -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. fastapi[standard] >= 0.115.0 # Required by FastAPI's form models in the OpenAI API server's audio transcriptions endpoint.
aiohttp aiohttp
openai >= 1.99.1 # For Responses API with reasoning content openai >= 1.99.1 # For Responses API with reasoning content
pydantic >= 2.11.7 pydantic >= 2.12.0
prometheus_client >= 0.18.0 prometheus_client >= 0.18.0
pillow # Required for image processing pillow # Required for image processing
prometheus-fastapi-instrumentator >= 7.0.0 prometheus-fastapi-instrumentator >= 7.0.0

View File

@ -44,4 +44,4 @@ numba == 0.61.2 # Required for N-gram speculative decoding
numpy numpy
runai-model-streamer[s3,gcs]==0.14.0 runai-model-streamer[s3,gcs]==0.14.0
fastsafetensors>=0.1.10 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

View File

@ -52,7 +52,7 @@ numba == 0.61.2 # Required for N-gram speculative decoding
numpy numpy
runai-model-streamer[s3,gcs]==0.14.0 runai-model-streamer[s3,gcs]==0.14.0
fastsafetensors>=0.1.10 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 decord==0.6.0
terratorch @ git+https://github.com/IBM/terratorch.git@1.1.rc3 # required for PrithviMAE test terratorch @ git+https://github.com/IBM/terratorch.git@1.1.rc3 # required for PrithviMAE test
gpt-oss >= 0.0.7; python_version > '3.11' gpt-oss >= 0.0.7; python_version > '3.11'

View File

@ -783,7 +783,7 @@ pycparser==2.22
# via cffi # via cffi
pycryptodomex==3.22.0 pycryptodomex==3.22.0
# via blobfile # via blobfile
pydantic==2.11.7 pydantic==2.12.0
# via # via
# -r requirements/test.in # -r requirements/test.in
# albumentations # albumentations
@ -797,7 +797,7 @@ pydantic==2.11.7
# openai-harmony # openai-harmony
# pydantic-extra-types # pydantic-extra-types
# ray # ray
pydantic-core==2.33.2 pydantic-core==2.41.1
# via pydantic # via pydantic
pydantic-extra-types==2.10.5 pydantic-extra-types==2.10.5
# via mistral-common # via mistral-common
@ -1224,7 +1224,7 @@ types-python-dateutil==2.9.0.20241206
# via arrow # via arrow
typeshed-client==2.8.2 typeshed-client==2.8.2
# via jsonargparse # via jsonargparse
typing-extensions==4.12.2 typing-extensions==4.15.0
# via # via
# aiosignal # aiosignal
# albumentations # albumentations
@ -1253,7 +1253,7 @@ typing-extensions==4.12.2
# typer # typer
# typeshed-client # typeshed-client
# typing-inspection # typing-inspection
typing-inspection==0.4.1 typing-inspection==0.4.2
# via pydantic # via pydantic
tzdata==2024.2 tzdata==2024.2
# via pandas # via pandas

View File

@ -111,17 +111,7 @@ def get_attr_docs(cls: type[Any]) -> dict[str, str]:
https://davidism.com/mit-license/ https://davidism.com/mit-license/
""" """
try: cls_node = ast.parse(textwrap.dedent(inspect.getsource(cls))).body[0]
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]
if not isinstance(cls_node, ast.ClassDef): if not isinstance(cls_node, ast.ClassDef):
raise TypeError("Given object was not a class.") raise TypeError("Given object was not a class.")