-
-
Notifications
You must be signed in to change notification settings - Fork 754
🐛 Fix TypeError
for fields annotated with Literal
#1439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
I have no idea how to add the proper labels to this PR, it looks like the permissions aren't set up to allow me to. |
TypeError
for fields annotated with Literal
@nsaccente, thanks for working on this! |
Sure. I'll try to get that done sometime this week. |
…del into bugfix-57/literal-satype
2aaef2d
to
3c024e2
Compare
I've been fighting with getting the tests to work. I've been able to get things to pass in some versions of python, but not others. Any guidance on how to run these CI tests locally? |
This PR addresses issue 57. The original issue explains that attempting to use a Literal type annotation in a SQLModel raises a type error from
issubclass
. This is becauseLiteral
is not a class, but a typing._SpecialForm, so static funcs likeisinstance
andissubclass
don't work with it.The fix was pretty straightforward, I just added a check before an
isinstance
orissubclass
would have been called that checksif type_ is Literal
.