FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

🐛 Fix type annotation in `SQLModel.__new__`, avoid explicitly returni… · hellow554/sqlmodel@5da82e2 · GitHub

Repository navigation

Commit 5da82e2

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

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎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)

Back | FazBrowse Home | New Git URL