-
Notifications
You must be signed in to change notification settings - Fork 4
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
support str|None , mapped_column, AnyURL #1
Conversation
Hi @honglei! Thanks for the PR. I've run the checks and they are failing. It seems to be some typing issues. I'm a bit busy atm so can't work this week, but I could help with some checks the next one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for the PR! Please check this typing errors
sqlmodel/main.py
Outdated
@@ -11,6 +11,7 @@ | |||
from typing import ( | |||
AbstractSet, | |||
Any, | |||
Annotated, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annotated was introduced in Python 3.9. Need to check python version and import it from typing_extensions if necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, use typing_extensions to import Annotated
.
sqlmodel/main.py
Outdated
return AutoString(length=meta.max_length) | ||
|
||
if get_origin(type_) is Annotated: | ||
type2 = type_.__args__[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mypy does not like this line:
Item "type" of "Optional[type]" has no attribute "args"
Maybe use https://docs.python.org/3/library/typing.html#typing.get_args
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! typing.get_args is much better.
sqlmodel/main.py
Outdated
if get_origin(type_) is Annotated: | ||
type2 = type_.__args__[0] | ||
if type2 is pydantic.AnyUrl: | ||
meta = type_.__metadata__[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Item "None" of "Optional[type]" has no attribute "metadata"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will use typing.get_args
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small fixes
@honglei Almost all typing errors are fixed. But there are some formatting errors now :/. Please consult the workflow logs to see the issues. |
I use ruff checked in Python3.7/debain10, all passed except code length. |
fix .model_copy(...) Pydantic V2
See fastapi#532 (comment)