Skip to content

Commit 0646f8c

Browse files
committed
Refactor: Simplify _is_new_type_instance logic and clean up class_registry typeignore
1 parent 026ab26 commit 0646f8c

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

sqlmodel/main.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import types
77
import typing
88
import uuid
9+
import weakref
910
from collections.abc import Callable, Mapping, Sequence, Set
1011
from dataclasses import dataclass
1112
from datetime import date, datetime, time, timedelta
@@ -811,10 +812,7 @@ def _is_typing_type_instance(annotation: Any, type_name: str) -> bool:
811812

812813

813814
def _is_new_type_instance(annotation: Any) -> bool:
814-
if sys.version_info >= (3, 10):
815-
return _is_typing_type_instance(annotation, "NewType")
816-
else:
817-
return hasattr(annotation, "__supertype__")
815+
return _is_typing_type_instance(annotation, "NewType")
818816

819817

820818
def _is_type_var_instance(annotation: Any) -> bool:
@@ -848,7 +846,7 @@ def resolve_type_alias(annotation: Any) -> Any:
848846
return resolution
849847

850848

851-
class_registry = weakref.WeakValueDictionary() # type: ignore
849+
class_registry = weakref.WeakValueDictionary()
852850

853851
default_registry = registry()
854852

0 commit comments

Comments
 (0)