From adf9b89c76c01ac83f0687acd8c26d3dc62eab46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Wed, 8 Oct 2025 19:23:36 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Workaround=20for=20Python?= =?UTF-8?q?=203.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastapi/_compat/shared.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fastapi/_compat/shared.py b/fastapi/_compat/shared.py index bfa5296dc..140c860c2 100644 --- a/fastapi/_compat/shared.py +++ b/fastapi/_compat/shared.py @@ -24,7 +24,13 @@ from starlette.datastructures import UploadFile from typing_extensions import Annotated, get_args, get_origin # Copy from Pydantic v2, compatible with v1 -if sys.version_info < (3, 10): +if sys.version_info < (3, 9): + # Pydantic no longer supports Python 3.8, this might be incorrect, but the code + # this is used for is also never reached in this codebase, as it's a copy of + # Pydantic's lenient_issubclass, just for compatibility with v1 + # TODO: remove when dropping support for Python 3.8 + WithArgsTypes: tuple[Any, ...] = () +elif sys.version_info < (3, 10): WithArgsTypes: tuple[Any, ...] = (typing._GenericAlias, types.GenericAlias) # pyright: ignore[reportAttributeAccessIssue] else: WithArgsTypes: tuple[Any, ...] = (