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. |
mbsantiago
left a comment
There was a problem hiding this comment.
Many thanks for the PR! Please check this typing errors
sqlmodel/main.py
Outdated
| from typing import ( | ||
| AbstractSet, | ||
| Any, | ||
| Annotated, |
There was a problem hiding this comment.
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.
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.
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
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.
Item "None" of "Optional[type]" has no attribute "metadata"
|
@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)