Skip to content

Commit a05a685

Browse files
committed
📝 Add handling for GenericAlias in type alias checks for Python 3.10
1 parent 05d32da commit a05a685

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

sqlmodel/_compat.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ def _is_type_alias_type_instance(annotation: Any) -> bool:
212212
if in_typing_extensions:
213213
check_type.append(typing_extensions.TypeAliasType)
214214

215+
if sys.version_info[:2] == (3, 10):
216+
if type(annotation) is types.GenericAlias:
217+
# In Python 3.10, TypeAliasType instances are of type GenericAlias
218+
return False
219+
215220
return check_type and isinstance(annotation, tuple(check_type))
216221

217222
def get_sa_type_from_type_annotation(annotation: Any) -> Any:

0 commit comments

Comments
 (0)