Conversation
This matches the documentation, which says: > A buffered text stream providing higher-level access to a BufferedIOBase > buffered binary stream. Cf python#10229
|
Also, the current annotations are unsound. You can pass in any |
|
Diff from mypy_primer, showing the effect of this PR on open source code: pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/capture.py:174: error: Returning Any from function declared to return "str" [no-any-return]
+ src/_pytest/capture.py:174: error: "BufferedIOBase" has no attribute "mode" [attr-defined]
+ src/_pytest/capture.py:466: error: Argument 1 to "EncodedFile" has incompatible type "IO[bytes]"; expected "BufferedIOBase" [arg-type]
+ testing/test_capture.py:1635: error: Argument 1 to "EncodedFile" has incompatible type "BinaryIO"; expected "BufferedIOBase" [arg-type]
rich (https://github.com/Textualize/rich)
+ rich/progress.py:1363: error: Argument 1 to "TextIOWrapper" has incompatible type "_Reader"; expected "BufferedIOBase" [arg-type]
urllib3 (https://github.com/urllib3/urllib3)
+ src/urllib3/util/ssltransport.py:165: error: Argument 1 to "TextIOWrapper" has incompatible type "BinaryIO"; expected "BufferedIOBase" [arg-type]
streamlit (https://github.com/streamlit/streamlit)
- lib/tests/streamlit/web/server/component_request_handler_test.py:161:38: error: Argument 1 to "TextIOWrapper" has incompatible type "str"; expected "IO[bytes]" [arg-type]
+ lib/tests/streamlit/web/server/component_request_handler_test.py:161:38: error: Argument 1 to "TextIOWrapper" has incompatible type "str"; expected "BufferedIOBase" [arg-type]
black (https://github.com/psf/black)
+ src/black/__init__.py:844:17: error: Argument 1 to "TextIOWrapper" has incompatible type "BinaryIO"; expected "BufferedIOBase" [arg-type]
+ src/black/__init__.py:888:13: error: Argument 1 to "TextIOWrapper" has incompatible type "BinaryIO"; expected "BufferedIOBase" [arg-type]
cwltool (https://github.com/common-workflow-language/cwltool)
+ cwltool/main.py:55: note: In module imported here:
+ cwltool/cwlprov/writablebagfile.py: note: In function "write_bag_file":
+ cwltool/cwlprov/writablebagfile.py:119:30: error: Argument 1 to "TextIOWrapper" has incompatible type "BinaryIO"; expected "BufferedIOBase" [arg-type]
+ cwltool/main.py: note: In function "main":
+ cwltool/main.py:965:43: error: Argument 1 to "TextIOWrapper" has incompatible type "BinaryIO"; expected "BufferedIOBase" [arg-type]
|
|
I'd be interested to see the mypy_primer results if we tried making it generic. It might be very disruptive, but it also might not. |
|
Ok, not sure why I replicated @JelleZijlstra's issue #10229. I tried to actually address one of the suggestions I made in there, but accidentally replicated it mostly. Although this PR is a little but more extensive, as it also adds |
|
I suggest we merge the two other PRs first, rerun the tests here and then I'll also do a test with a generic |
Incorporates changes from python#10266, so we don't have two PRs open.
|
I merged the additional changes into #10229, closing this here. |
This matches the documentation, which says:
Cf #10229