You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mypy consistently fails to type-check the initialization of SQLModel classes. This occurs both when using Field() and without it. Specifically:
mypy fails to detect missing required arguments during class initialization
mypy fails to detect type mismatches during class initialization
It's important to note that mypy does correctly type-check assignments after initialization.
Interestingly, Pyright seems to handle these cases correctly, suggesting this might be specific to mypy's interaction with SQLModel.
I thought it would be worth mentioning here in case others have encountered similar issues or if there might be a way to improve SQLModel's compatibility with mypy
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
First Check
Commit to Help
Example Code
Description
Mypy consistently fails to type-check the initialization of SQLModel classes. This occurs both when using Field() and without it. Specifically:
It's important to note that mypy does correctly type-check assignments after initialization.
Interestingly, Pyright seems to handle these cases correctly, suggesting this might be specific to mypy's interaction with SQLModel.
I thought it would be worth mentioning here in case others have encountered similar issues or if there might be a way to improve SQLModel's compatibility with mypy
Operating System
Linux
Operating System Details
No response
SQLModel Version
0.0.22
Python Version
3.12.5
Additional Context
mypy versions tested (default config):
1.4.1
1.11.2
Beta Was this translation helpful? Give feedback.
All reactions