Add opt-in httpx import alias helper#968
Conversation
|
Interesting. I'm still new to this and taking a look, but I can't reproduce the coverage failure locally: Update: I'm an idiot and forgot to run with coverage. I'll get this updated in a bit |
|
Hey @Kludex, friendly ping. Can you take a look at this PR when you get a chance? Happy to make any updates if you think they're necessary. |
| httpx2_module = sys.modules["httpx2"] | ||
|
|
||
| existing_httpx_module = sys.modules.get("httpx") | ||
| if existing_httpx_module is httpx2_module: |
There was a problem hiding this comment.
Is this check needed? Assuming this gets run only once, existing_httpx_module will be None. If it's run twice, it prevents the next check from running.
|
Don't forget about httpcore2, otherwise vcrpy will break. |
|
Why was this closed? |
|
Hey @Kilo59, apologies for closing without a comment. I closed this PR since I haven't noticed any interest from the maintainers in the past two months and I also don't have the time right now to move this forward. Additionally, I need an HTTP client that supports full-duplex streaming and more performant, so httpx2 isn't the best choice (at least not right now, I have high hopes for the future🤞). Anyone is more than welcome to build on top of these changes in the same or separate PR. |
Summary
Hey team! I'm interested in this project and saw in #963 that there was a need for aliasing
httpx2ashttpx. I also saw that a Pydantic maintainer reacted to one suggested approach, indicating this is something the team may be open to adding.In this PR, I've added a
httpx2.enable_httpx_alias(), which users can opt in to when they needimport httpxto resolve tohttpx2.This is useful for staged migrations where an application or dependency tree still contains existing
httpximports, but the environment is moving tohttpx2.The helper is intentionally explicit and conservative. It fails if the real
httpxpackage is installed or if anhttpxmodule has already been imported.If you want to see this take a different approach, I'm open to updating this PR, just let me know.
Thanks!
Checklist