-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
update codebase to support fastapi>=0.100.0 and pydantic>=2.0.0 #447
Conversation
✅ Deploy Preview for fastapi-filter ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@johnybx Thanks so much for putting time into this, I'll try to review/help as much as I can 👍🏻 And yeah a major version bump is the way to go. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #447 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 6
Lines 180 193 +13
=========================================
+ Hits 180 193 +13
|
… upgrade of dependencies
I came up with different approach which does not introduce breaking changes to how |
Signed-off-by: johnybx <[email protected]>
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.
That look really great, thank you so much for all your work!
I just have a few nits but we can ship it after that 🚀
Co-authored-by: Arthur Rio <[email protected]> Signed-off-by: johnybx <[email protected]>
Co-authored-by: Arthur Rio <[email protected]> Signed-off-by: johnybx <[email protected]>
Co-authored-by: Arthur Rio <[email protected]> Signed-off-by: johnybx <[email protected]>
Signed-off-by: johnybx <[email protected]>
Signed-off-by: johnybx <[email protected]>
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.
Just that one last question so that we avoid confusion for people hitting that edge case, otherwise looks like it's ready to go! 👍🏻
fastapi_filter/base/filter.py
Outdated
if len(annotation_args) == 1: | ||
annotation = annotation_args[0] | ||
# Not sure what to do if there is more then 1 value 🤔 | ||
# Do we need to handle Optional[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.
We should raise an exception for now until we figure this out?
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.
I left the comment here for future as a note that union of list
type with other types is not supported just in case someone thought that for example type like list[str] | int | None
should work with filter. At the same time I don't think that it is reasonable to support such types ( I mean transformation of list
part to str
split by comma in such complex types) without knowing real usecase. Also supporting such types would be problem in case of types like list[str] | str | None
.
Raising exception here is not a good idea because the exception would be raised on any type which is union basically so for example int | float
because this is union type and will have length 2 but at the same time it is valid type which we want to skip. Maybe I should just update comment to specifically mention that I am not sure what to do if the type is combination of list
and other types like list[str] | str
? Because list filtering will not work in that case 🤔
What do you think ?
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.
@johnybx Do you have time to make that change or do you want me to do it?
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.
@arthurio sure I just wasn't sure if you are fine with what I wrote. I added note to code and also added small section about current limitations of union types in filters with list. Let me know if something should be changed 👍
fastapi_filter/base/filter.py
Outdated
if len(annotation_args) == 1: | ||
annotation = annotation_args[0] | ||
# Not sure what to do if there is more then 1 value 🤔 | ||
# Do we need to handle Optional[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.
I left the comment here for future as a note that union of list
type with other types is not supported just in case someone thought that for example type like list[str] | int | None
should work with filter. At the same time I don't think that it is reasonable to support such types ( I mean transformation of list
part to str
split by comma in such complex types) without knowing real usecase. Also supporting such types would be problem in case of types like list[str] | str | None
.
Raising exception here is not a good idea because the exception would be raised on any type which is union basically so for example int | float
because this is union type and will have length 2 but at the same time it is valid type which we want to skip. Maybe I should just update comment to specifically mention that I am not sure what to do if the type is combination of list
and other types like list[str] | str
? Because list filtering will not work in that case 🤔
What do you think ?
fastapi_filter/base/filter.py
Outdated
if len(annotation_args) == 1: | ||
annotation = annotation_args[0] | ||
# Not sure what to do if there is more then 1 value 🤔 | ||
# Do we need to handle Optional[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.
@arthurio sure I just wasn't sure if you are fine with what I wrote. I added note to code and also added small section about current limitations of union types in filters with list. Let me know if something should be changed 👍
@arthurio sorry that it took so long but I just realized that |
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.
Let's do it! Thanks again for all the hard work, really appreciate it.
Hi,
I updated codebase to support fastapi>=0.100.0 and pydantic>=2.0.0 ( this is breaking change ). I tried to keep same features and interface but when it comes to
with_prefix
function there were changes required. Currently with pydantic>=2.0.0 when you define attribute like in this example:you get error:
The only workaround I found (currently) is to update
with_prefix
to generate the wrapped model and annotation withPlainValidator
.TODO: