Skip to content

Alias httpcore imports to httpcore2 in alias_httpx()#1082

Open
Kludex wants to merge 1 commit into
mainfrom
alias-httpcore
Open

Alias httpcore imports to httpcore2 in alias_httpx()#1082
Kludex wants to merge 1 commit into
mainfrom
alias-httpcore

Conversation

@Kludex

@Kludex Kludex commented Jul 23, 2026

Copy link
Copy Markdown
Member

#1077 only aliased httpx imports, but dependencies importing httpcore directly (e.g. custom transports catching low-level exceptions) were still resolving to the old package. alias_httpx() now also makes import httpcore resolve to httpcore2, with the same submodule handling and already-imported guard.

AI Disclaimer

This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.

Review in cubic

@Kludex
Kludex deployed to cloudflare July 23, 2026 19:51 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown

Docs preview:

@codspeed-hq

codspeed-hq Bot commented Jul 23, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 15 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing alias-httpcore (a7e9be0) with main (c6028d9)

Open in CodSpeed

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/httpx2/httpx2/_alias.py">

<violation number="1" location="src/httpx2/httpx2/_alias.py:53">
P3: The docstring says dependencies importing `httpcore` share `httpx2` classes, but this alias exposes `httpcore2` classes instead. Describing the two package-specific targets would avoid misleading callers about which low-level exception and type hierarchy they receive.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic


Intended for applications migrating from `httpx`, so that dependencies still
importing `httpx` share the `httpx2` classes. Libraries should never call this.
importing `httpx` or `httpcore` share the `httpx2` classes. Libraries should never call this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The docstring says dependencies importing httpcore share httpx2 classes, but this alias exposes httpcore2 classes instead. Describing the two package-specific targets would avoid misleading callers about which low-level exception and type hierarchy they receive.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/httpx2/httpx2/_alias.py, line 53:

<comment>The docstring says dependencies importing `httpcore` share `httpx2` classes, but this alias exposes `httpcore2` classes instead. Describing the two package-specific targets would avoid misleading callers about which low-level exception and type hierarchy they receive.</comment>

<file context>
@@ -30,29 +35,34 @@ def find_spec(
 
     Intended for applications migrating from `httpx`, so that dependencies still
-    importing `httpx` share the `httpx2` classes. Libraries should never call this.
+    importing `httpx` or `httpcore` share the `httpx2` classes. Libraries should never call this.
 
-    Must be called before anything imports `httpx`. Calling it again is a no-op.
</file context>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant