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
I used the GitHub search to find a similar question and didn't find it.
I searched the SQLModel documentation, with the integrated search.
I already searched in Google "How to X in SQLModel" and didn't find any information.
I already read and followed all the tutorial in the docs and didn't find an answer.
I already checked if it is not related to SQLModel but to Pydantic.
I already checked if it is not related to SQLModel but to SQLAlchemy.
Commit to Help
I commit to help with one of those options 👆
Example Code
##################################### REQUIREMENTS.TXT ######################## For running SQL queriessqlmodel==0.0.14############################ .VSCODE SETTINGS.JSON############################
{
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python3.11",
"python.analysis.typeCheckingMode": "strict",
"python.analysis.diagnosticMode": "workspace",
}
#################################### MAIN.PY #################################fromsqlmodelimportSQLModelclassUser(SQLModel):
"""Gives some basic information about the user."""user_id: intclassProfile(object):
"""Contains social information about the user."""name: strclassSettings(SQLModel):
"""Contains the user's settings."""user: Userprofile: Profileuse_dark_mode: boolSettings(
user=None, # This line does not raise static errors with pylanceprofile=None, # This line does raise static errors with pylanceuse_dark_mode=True,
)
Description
SITUATION:
I recently updated to SQLModel 0.0.14 and have since started experiencing static typing issues with SQLModel.
COMPLICATION
Whenever I nest two SQLModels, static typing fails to execute correctly.
The example above is one instance of this behavior:
User inherits from SQLModel
Profile is a regular Python class (inheriting from object)
Settings contains nested User and Profile models, both of which are not optional
When I pass None to the the user and profile properties in the Settings constructor, both of them should throw static errors (None is not an acceptable subtype of User and Profile after all), but for some reason the user property accepts None without issues.
QUESTION
The code above minimally reproduces the faulty behavior on my machine. What am I doing wrong here? Is this a bug in SQLModel or my setup?
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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
First Check
Commit to Help
Example Code
Description
SITUATION:
I recently updated to SQLModel 0.0.14 and have since started experiencing static typing issues with SQLModel.
COMPLICATION
Whenever I nest two SQLModels, static typing fails to execute correctly.
The example above is one instance of this behavior:
Userinherits from SQLModelProfileis a regular Python class (inheriting from object)Settingscontains nested User and Profile models, both of which are not optionalSettingsconstructor, both of them should throw static errors (None is not an acceptable subtype of User and Profile after all), but for some reason the user property accepts None without issues.QUESTION
The code above minimally reproduces the faulty behavior on my machine. What am I doing wrong here? Is this a bug in SQLModel or my setup?
Operating System
macOS
Operating System Details
I'm running all of this in VSCode
SQLModel Version
0.0.14
Python Version
3.11.6
Additional Context
No response
All reactions