Skip to content

Commit 5da82e2

Browse files
authored
šŸ› Fix type annotation in SQLModel.__new__, avoid explicitly returning Any (#1846)
1 parent 9a44fc4 commit 5da82e2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ā€Žsqlmodel/main.pyā€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,9 @@ class SQLModel(BaseModel, metaclass=SQLModelMetaclass, registry=default_registry
814814
__allow_unmapped__ = True # https://docs.sqlalchemy.org/en/20/changelog/migration_20.html#migration-20-step-six
815815
model_config = SQLModelConfig(from_attributes=True)
816816

817-
def __new__(cls, *args: Any, **kwargs: Any) -> Any:
817+
# Typing spec says `__new__` returning `Any` overrides normal constructor
818+
# behavior, but a missing annotation does not:
819+
def __new__(cls, *args: Any, **kwargs: Any): # type: ignore[no-untyped-def]
818820
new_object = super().__new__(cls)
819821
# SQLAlchemy doesn't call __init__ on the base class when querying from DB
820822
# Ref: https://docs.sqlalchemy.org/en/14/orm/constructors.html

0 commit comments

Comments
Ā (0)