8000 Fix for `typing-extensions@main` · pydantic/pydantic@389f32a · GitHub
[go: up one dir, main page]

Skip to content

Commit 389f32a

Browse files
committed
Fix for typing-extensions@main
1 parent dd19372 commit 389f32a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pydantic/_internal/_typing_extra.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,17 @@ def unpack_annotated(annotation: Any, /) -> tuple[Any, list[Any]]:
152152
typ, sub_meta = unpack_annotated(typ)
153153
metadata = sub_meta + metadata
154154
return typ, metadata
155-
elif is_type_alias_type(annotation):
155+
156+
if sys.version_info[:2] == (3, 10):
157+
# Parametrized PEP 695 type aliases are instances of `types.GenericAlias` in typing_extensions>=4.13.0.
158+
# On Python 3.10, with `Alias[int]` being a such an instance of `GenericAlias`,
159+
# `isinstance(Alias[int], TypeAliasType)` returns `True`.
160+
# See https://github.com/python/cpython/issues/89828.
161+
ann_is_type_alias = type(annotation) is not types.GenericAlias and is_type_alias_type(annotation)
162+
else:
163+
ann_is_type_alias = is_type_alias_type(annotation)
164+
165+
if ann_is_type_alias:
156166
try:
157167
value = annotation.__value__
158168
except NameError:

0 commit comments

Comments
 (0)
0