Skip to content

Commit 07702ad

Browse files
committed
Add a version guard
1 parent d1837c4 commit 07702ad

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ninja/signature/details.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pydantic.fields import FieldInfo
99
from pydantic_core import PydanticUndefined
1010
from typing_extensions import Annotated, get_args, get_origin
11+
from sys import version_info
1112

1213
from ninja import UploadedFile
1314
from ninja.compatibility.util import UNION_TYPES
@@ -220,7 +221,10 @@ def _get_param_type(self, name: str, arg: inspect.Parameter) -> FuncParam:
220221
annotation = arg.annotation
221222
default = arg.default
222223

223-
if get_origin(annotation) is Annotated:
224+
# TODO: Remove version check once support for <=3.8 is dropped.
225+
# Annotated[] is only available in 3.9+ per
226+
# https://docs.python.org/3/library/typing.html#typing.Annotated
227+
if get_origin(annotation) is Annotated and version_info >= (3, 9):
224228
args = get_args(annotation)
225229
if isinstance(args[-1], Param):
226230
prev_default = default

0 commit comments

Comments
 (0)