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

Skip to content

Commit 3153ed2

Browse files
committed
Fix for typing-extensions@main
1 parent d663eed commit 3153ed2

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
@@ -168,7 +168,17 @@ def unpack_annotated(annotation: Any, /) -> tuple[Any, list[Any]]:
168168
typ, sub_meta = unpack_annotated(typ)
169169
metadata = sub_meta + metadata
170170
return typ, metadata
171-
elif is_type_alias_type(annotation):
171+
172+
if sys.version_info[:2] == (3, 10):
173+
# Parametrized PEP 695 type aliases are instances of `types.GenericAlias` in typing_extensions>=4.13.0.
174+
# On Python 3.10, with `Alias[int]` being a such an instance of `GenericAlias`,
175+
# `isinstance(Alias[int], TypeAliasType)` returns `True`.
176+
# See https://github.com/python/cpython/issues/89828.
177+
ann_is_type_alias = type(annotation) is not types.GenericAlias and is_type_alias_type(annotation)
178+
else:
179+
ann_is_type_alias = is_type_alias_type(annotation)
180+
181+
if ann_is_type_alias:
172182
try:
173183
value = annotation.__value__
174184
except NameError:

0 commit comments

Comments
 (0)
0