Httpx and Pydantic V2 fixes#29
Open
martincpt wants to merge 9 commits into
Open
Conversation
Owner
|
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. |
Author
|
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? |
Owner
|
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. |
Author
|
@abersheeran, I dropped support for 3.7, 3.8 and added 3.11, 3.12 to the ci.yaml |
abersheeran
reviewed
May 6, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
yieldbroke due to changes inhttpx >= 0.24. Specifically,aiter_linesno 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_modelfor v2, the code now usespydantic.RootModelwhen needed.3. Test fine-tuning
I removed unnecessary
sleepcalls from the generator tests. They added significant overhead to the test runtime—tests now complete in under a second. Ideally, tests should avoidsleepaltogether (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!