Make BufferedReader generic over a protocol#13533
Merged
srittau merged 8 commits intopython:mainfrom May 11, 2025
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Collaborator
Author
|
Looking at the primer hits: Both |
Collaborator
Author
|
Pingity pong. If this gets merged, I'd try the same with |
JelleZijlstra
approved these changes
May 11, 2025
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: streamlit (https://github.com/streamlit/streamlit)
- lib/tests/streamlit/elements/audio_test.py:78:38: error: Argument 1 to "_calculate_file_id" has incompatible type "Union[str, Path, bytes, BytesIO, RawIOBase, BufferedReader, Any, None]"; expected "bytes" [arg-type]
+ lib/tests/streamlit/elements/audio_test.py:78:38: error: Argument 1 to "_calculate_file_id" has incompatible type "Union[str, Path, bytes, BytesIO, RawIOBase, BufferedReader[_BufferedReaderStream], Any, None]"; expected "bytes" [arg-type]
werkzeug (https://github.com/pallets/werkzeug)
- tests/test_wsgi.py:158: error: Incompatible types in assignment (expression has type "TextIOWrapper[BufferedReader]", variable has type "LimitedStream") [assignment]
+ tests/test_wsgi.py:158: error: Incompatible types in assignment (expression has type "TextIOWrapper[BufferedReader[LimitedStream]]", variable has type "LimitedStream") [assignment]
+ tests/test_wsgi.py:158: error: Value of type variable "_BufferedReaderStreamT" of "BufferedReader" cannot be "LimitedStream" [type-var]
urllib3 (https://github.com/urllib3/urllib3)
+ test/test_response.py:770: error: Unused "type: ignore" comment [unused-ignore]
+ test/test_response.py:770: error: Value of type variable "_BufferedReaderStreamT" of "BufferedReader" cannot be "HTTPResponse" [type-var]
+ test/test_response.py:770: note: Error code "type-var" not covered by "type: ignore" comment
+ test/test_response.py:782: error: Unused "type: ignore" comment [unused-ignore]
+ test/test_response.py:782: error: Value of type variable "_BufferedReaderStreamT" of "BufferedReader" cannot be "HTTPResponse" [type-var]
+ test/test_response.py:782: note: Error code "type-var" not covered by "type: ignore" comment
+ test/test_response.py:787: error: Unused "type: ignore" comment [unused-ignore]
+ test/test_response.py:787: error: Value of type variable "_BufferedReaderStreamT" of "BufferedReader" cannot be "HTTPResponse" [type-var]
+ test/test_response.py:787: note: Error code "type-var" not covered by "type: ignore" comment
+ test/test_response.py:800: error: Unused "type: ignore" comment [unused-ignore]
+ test/test_response.py:800: error: Value of type variable "_BufferedReaderStreamT" of "BufferedReader" cannot be "HTTPResponse" [type-var]
+ test/test_response.py:800: note: Error code "type-var" not covered by "type: ignore" comment
materialize (https://github.com/MaterializeInc/materialize)
- misc/python/materialize/mzbuild.py:825: error: Incompatible types in assignment (expression has type "BufferedRandom", variable has type "BufferedReader") [assignment]
+ misc/python/materialize/mzbuild.py:825: error: Incompatible types in assignment (expression has type "BufferedRandom", variable has type "BufferedReader[_BufferedReaderStream]") [assignment]
|
mmingyu
pushed a commit
to mmingyu/typeshed
that referenced
this pull request
May 16, 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.
Works towards #13495