From: Carl Meyer Date: Thu, 2 Apr 2026 20:58:24 +0000 (-0700) Subject: 🐛 Fix type annotation in `SQLModel.__new__`, avoid explicitly returning `Any` (#1846) X-Git-Tag: 0.0.38~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5da82e2d741e6ab94580395ee637721ca0cb315e;p=thirdparty%2Ffastapi%2Fsqlmodel.git 🐛 Fix type annotation in `SQLModel.__new__`, avoid explicitly returning `Any` (#1846) --- diff --git a/sqlmodel/main.py b/sqlmodel/main.py index 300031de8..17d64e8ff 100644 --- a/sqlmodel/main.py +++ b/sqlmodel/main.py @@ -814,7 +814,9 @@ class SQLModel(BaseModel, metaclass=SQLModelMetaclass, registry=default_registry __allow_unmapped__ = True # https://docs.sqlalchemy.org/en/20/changelog/migration_20.html#migration-20-step-six model_config = SQLModelConfig(from_attributes=True) - def __new__(cls, *args: Any, **kwargs: Any) -> Any: + # Typing spec says `__new__` returning `Any` overrides normal constructor + # behavior, but a missing annotation does not: + def __new__(cls, *args: Any, **kwargs: Any): # type: ignore[no-untyped-def] new_object = super().__new__(cls) # SQLAlchemy doesn't call __init__ on the base class when querying from DB # Ref: https://docs.sqlalchemy.org/en/14/orm/constructors.html