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

馃悰 Fix type annotation in `SQLModel.__new__`, avoid explicitly returning `Any` by carljm 路 Pull Request #1846 路 fastapi/sqlmodel 路 GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 3 additions & 1 deletion sqlmodel/main.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

Back | FazBrowse Home | New Git URL