First Check
Commit to Help
Example Code
fromsqlmodelimportSQLModelclasstest(SQLModel):
attr: intdesc: strclassreal(test, table=True):
val: floattest_inst: test=test(attr=1, desc='test_inst')
real_inst: real=real.parse_obj(test_inst.dict())
"""(method) parse_obj: (obj: Any, update: Dict[str, Any] | None = None) -> SQLModelExpression of type "SQLModel" cannot be assigned to declared type "real" "SQLModel" is incompatible with "real"PylancereportGeneralTypeIssues"""
Description
real.parse_obj return type should be real.
Wanted Solution
# sqlmodel/main.pyfromtypingimportTypeVar_T=TypeVar("_T", bound="SQLModel")
(...)
# line no.569@classmethoddefparse_obj(
cls: Type[_T], obj: Any, update: Optional[Dict[str, Any]] =None
) ->_T:
obj=cls._enforce_dict_if_root(obj)
# SQLModel, support update dictifupdateisnotNone:
obj= {**obj, **update}
# End SQLModel support dictreturnsuper().parse_obj(obj)Wanted Code
...
Alternatives
It's being used temporarily like this.
fromtypingimportAny, TypeVar, castfromsqlmodelimportSQLModel_T=TypeVar("_T", bound=SQLModel)
classfix_parse_obj_model(SQLModel):
@classmethoddefparse_obj(cls: type[_T], obj: Any, update: dict[str, Any] |None=None) ->_T:
returncast(_T, super().parse_obj(obj, update))Operating System
Linux
Operating System Details
OS: Arch Linux x86_64
Host: 82FX Yoga Slim 7 Pro 14ITL5
Kernel: 5.17.4-arch1-1
Uptime: 3 hours, 32 mins
Packages: 969 (pacman), 23 (flatpak)
Shell: zsh 5.8.1
Resolution: 2240x1400, 2560x1080
DE: GNOME 42.0
WM: Mutter
WM Theme: Adwaita
Theme: Arc [GTK2/3]
Icons: Papirus [GTK2/3]
Terminal: vscode
CPU: 11th Gen Intel i5-1135G7 (8) @ 4.200GHz
GPU: Intel TigerLake-LP GT2 [Iris Xe Graphics]
GPU: NVIDIA GeForce MX450
Memory: 5423MiB / 15785MiB
SQLModel Version
0.0.6
Python Version
Python 3.10.4
Additional Context
I'd like to do a "pull requests"
shame I'm not used to git yet...
First Check
Commit to Help
Example Code
Description
real.parse_obj return type should be real.
Wanted Solution
Wanted Code
...
Alternatives
It's being used temporarily like this.
Operating System
Linux
Operating System Details
OS: Arch Linux x86_64
Host: 82FX Yoga Slim 7 Pro 14ITL5
Kernel: 5.17.4-arch1-1
Uptime: 3 hours, 32 mins
Packages: 969 (pacman), 23 (flatpak)
Shell: zsh 5.8.1
Resolution: 2240x1400, 2560x1080
DE: GNOME 42.0
WM: Mutter
WM Theme: Adwaita
Theme: Arc [GTK2/3]
Icons: Papirus [GTK2/3]
Terminal: vscode
CPU: 11th Gen Intel i5-1135G7 (8) @ 4.200GHz
GPU: Intel TigerLake-LP GT2 [Iris Xe Graphics]
GPU: NVIDIA GeForce MX450
Memory: 5423MiB / 15785MiB
SQLModel Version
0.0.6
Python Version
Python 3.10.4
Additional Context
I'd like to do a "pull requests"
shame I'm not used to git yet...