-
-
Notifications
You must be signed in to change notification settings - Fork 16
Httpx and Pydantic V2 fixes #29
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: master
Are you sure you want to change the base?
Httpx and Pydantic V2 fixes #29
Conversation
I'm glad you like this library. As long as you can fix the CI and get the unit tests to pass correctly, I will merge this PR soon. |
I've checked just to be certain. The unit tests are passing correctly. I believe there's something wrong with the CI. Could you please take a look at it? Set up Python 3.7
Run actions/setup-python@v2
Version 3.7 was not found in the local cache
Error: The operation was canceled. Also, I don't have any permission to rerun the CI. Maybe it was a temporary issue. Could you please try to rerun it? |
It seems that GitHub has dropped support for 3.7. Based on the current popular Python versions, we can drop unit tests for 3.7 and 3.8. |
@abersheeran, I dropped support for 3.7, 3.8 and added 3.11, 3.12 to the ci.yaml |
First of all, thank you for this fantastic package. 🙌
I really like the use of generators and yield statements. I found it extremely innovative, but unfortunately, it didn't work straightaway on my end. So, here I am, excited to contribute and send this fix.
I’m also glad this project builds on top of uvicorn, and comes with OpenAPI documentation—huge pluses all around!
What's included in this PR:
1. Fix for broken generators with the latest httpx client
Closes #27
This addresses an issue where generators using
yield
broke due to changes inhttpx >= 0.24
. Specifically,aiter_lines
no longer includes line breaks and instead yields empty strings. This case has to be handled in the same logic that previously managed line breaks.2. Fix for OpenAPI docs generation when using root return types with Pydantic v2
Closes #28
Partial support for pydantic v2 is added by detecting the installed version and using the appropriate method for model creation in OpenAPI docs. Since
__root__
is no longer available inpydantic.create_model
for v2, the code now usespydantic.RootModel
when needed.3. Test fine-tuning
I removed unnecessary
sleep
calls from the generator tests. They added significant overhead to the test runtime—tests now complete in under a second. Ideally, tests should avoidsleep
altogether (or mock time-based behavior) to keep the feedback loop fast during development.Thanks again for this fantastic package! 🙏
I hope you agree with the changes and find them useful. Looking forward to your feedback and, hopefully, to getting this merged soon!