Skip to content

Commit daadf43

Browse files
committed
📝 Update _is_new_type_instance to handle Python 3.10 compatibility
1 parent a86418c commit daadf43

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sqlmodel/_compat.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,10 @@ def _is_typing_type_instance(annotation: Any, type_name: str) -> bool:
210210
return bool(check_type) and isinstance(annotation, tuple(check_type))
211211

212212
def _is_new_type_instance(annotation: Any) -> bool:
213-
return _is_typing_type_instance(annotation, "NewType")
213+
if sys.version_info >= (3, 10):
214+
return _is_typing_type_instance(annotation, "NewType")
215+
else:
216+
return hasattr(annotation, "__supertype__")
214217

215218
def _is_type_var_instance(annotation: Any) -> bool:
216219
return _is_typing_type_instance(annotation, "TypeVar")

0 commit comments

Comments
 (0)