Skip to content

Use same module (httpx|httpx2) for type checking as for runtime#3304

Merged
Kludex merged 1 commit into
Kludex:mainfrom
leifwar:type-checking
May 30, 2026
Merged

Use same module (httpx|httpx2) for type checking as for runtime#3304
Kludex merged 1 commit into
Kludex:mainfrom
leifwar:type-checking

Conversation

@leifwar

@leifwar leifwar commented May 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Using different module when type checking (httpx) compared to runtime (httpx2) will cause type
checkers like pyright to fail. This PR solves this issue mentioned in #3302

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

Use same module (httpx|httpx2) for type checking as for runtime

@Kludex

Kludex commented May 30, 2026

Copy link
Copy Markdown
Owner

Yes, this is what I meant.

@Kludex Kludex merged commit 9cb1553 into Kludex:main May 30, 2026
9 checks passed
@Kludex Kludex mentioned this pull request May 31, 2026
Kludex added a commit that referenced this pull request May 31, 2026
@alicederyn

alicederyn commented Jun 9, 2026

Copy link
Copy Markdown

This seems to have lost typing information: the return type of TestClient.get (according to mypy at least) is now Any, not httpx._models.Response. Is there something that needs to be done differently to get the typing information back? If so, can it be added to the release notes?

@alicederyn

alicederyn commented Jun 9, 2026

Copy link
Copy Markdown

It seems like I could add the starlette[full] extra to pull in httpx2 — is that the recommendation? Ideally I'd have preferred a starlette[testclient] extra with just httpx2, if that's possible and something you'd be willing to support going forwards.

edit Oh, that's only on main, too, not in the released version. I see #3323 / #3320 are pertinent, I'll move to the discussion.

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.

3 participants