Revert bundled httpx stubs (fixes #4366) - #4371
Open
anushamukka-dev wants to merge 1 commit into
Open
Conversation
Summary: The bundled httpx stubs added in D110685002 caused a diagnostics regression between Pyrefly 1.1.1 and 1.2.0-dev.3 (GitHub facebook#4366): code using `httpx.MockTransport` that type-checked cleanly in 1.1.1 started reporting missing-attribute errors (22 new diagnostics in one corpus repo). Original intent of D110685002: mirror the existing bundled stubs (boto3, pandas, etc.) so that httpx users get out-of-the-box type checking even without the library installed locally / discoverable by the module resolver. The slip-up: unlike those libraries, httpx ships `py.typed` with full inline annotations -- it is its own authoritative type source. The hand-written bundled stubs were therefore both unnecessary and, worse, incomplete: they omitted `_transports/mock.pyi` and never re-exported `MockTransport` from `__init__.pyi`. Because a bundled stub shadows the upstream inline types, this turned a fully-typed public API into false-positive diagnostics. (The stubs were also added without a corresponding entry in `stubs_metadata.json`.) The fix: remove the entire `httpx-stubs/` tree (all 19 vendored files), reverting D110685002. Import resolution then falls back to httpx's own authoritative inline types, which are complete and include `MockTransport`. Why remove rather than patch `MockTransport`: adding the one missing symbol would only close today's gap. Maintaining a hand-written stub for an already-fully-typed library commits us to tracking parity with every future httpx release -- ongoing drift and maintenance cost for no benefit over the upstream types. Removal is the correct, durable fix. Differential Revision: D114158493
Contributor
|
@anushamukka-dev has exported this pull request. If you are a Meta employee, you can view the originating Diff in D114158493. |
Unable to generate the flame graphsThe performance report has correctly been generated, but there was an internal error while generating the flame graphs for this run. We're working on fixing the issue. Feel free to contact us on Discord or at support@codspeed.io if the issue persists. |
yangdanny97
approved these changes
Jul 30, 2026
yangdanny97
left a comment
Contributor
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
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.
Summary:
The bundled httpx stubs added in D110685002 caused a diagnostics regression between Pyrefly 1.1.1 and 1.2.0-dev.3 (GitHub #4366): code using
httpx.MockTransportthat type-checked cleanly in 1.1.1 started reporting missing-attribute errors (22 new diagnostics in one corpus repo).Original intent of D110685002: mirror the existing bundled stubs (boto3, pandas, etc.) so that httpx users get out-of-the-box type checking even without the library installed locally / discoverable by the module resolver.
The slip-up: unlike those libraries, httpx ships
py.typedwith full inline annotations -- it is its own authoritative type source. The hand-written bundled stubs were therefore both unnecessary and, worse, incomplete: they omitted_transports/mock.pyiand never re-exportedMockTransportfrom__init__.pyi. Because a bundled stub shadows the upstream inline types, this turned a fully-typed public API into false-positive diagnostics. (The stubs were also added without a corresponding entry instubs_metadata.json.)The fix: remove the entire
httpx-stubs/tree (all 19 vendored files), reverting D110685002. Import resolution then falls back to httpx's own authoritative inline types, which are complete and includeMockTransport.Why remove rather than patch
MockTransport: adding the one missing symbol would only close today's gap. Maintaining a hand-written stub for an already-fully-typed library commits us to tracking parity with every future httpx release -- ongoing drift and maintenance cost for no benefit over the upstream types. Removal is the correct, durable fix.Differential Revision: D114158493