typeshed icon indicating copy to clipboard operation
typeshed copied to clipboard

Make BufferedWriter generic over a protocol

Open srittau opened this issue 9 months ago • 6 comments

srittau avatar May 11 '25 16:05 srittau

Closes: #13495.

srittau avatar May 11 '25 16:05 srittau

Diff from mypy_primer, showing the effect of this PR on open source code:

ibis (https://github.com/ibis-project/ibis)
- ibis/expr/visualize.py:182: error: Incompatible types in assignment (expression has type "BufferedWriter", variable has type "_TemporaryFileWrapper[bytes]")  [assignment]
+ ibis/expr/visualize.py:182: error: Incompatible types in assignment (expression has type "BufferedWriter[_BufferedWriterStream]", variable has type "_TemporaryFileWrapper[bytes]")  [assignment]

urllib3 (https://github.com/urllib3/urllib3)
+ src/urllib3/util/ssltransport.py:156: error: Value of type variable "_BufferedWriterStreamT" of "BufferedRWPair" cannot be "SocketIO"  [type-var]
+ src/urllib3/util/ssltransport.py:156: note: Error code "type-var" not covered by "type: ignore" comment
+ src/urllib3/util/ssltransport.py:161: error: Value of type variable "_BufferedWriterStreamT" of "BufferedWriter" cannot be "SocketIO"  [type-var]

github-actions[bot] avatar May 11 '25 16:05 github-actions[bot]

Diff from mypy_primer, showing the effect of this PR on open source code:

ibis (https://github.com/ibis-project/ibis)
- ibis/expr/visualize.py:182: error: Incompatible types in assignment (expression has type "BufferedWriter", variable has type "_TemporaryFileWrapper[bytes]")  [assignment]
+ ibis/expr/visualize.py:182: error: Incompatible types in assignment (expression has type "BufferedWriter[_BufferedWriterStream]", variable has type "_TemporaryFileWrapper[bytes]")  [assignment]

github-actions[bot] avatar May 11 '25 17:05 github-actions[bot]

Diff from mypy_primer, showing the effect of this PR on open source code:

ibis (https://github.com/ibis-project/ibis)
- ibis/expr/visualize.py:182: error: Incompatible types in assignment (expression has type "BufferedWriter", variable has type "_TemporaryFileWrapper[bytes]")  [assignment]
+ ibis/expr/visualize.py:182: error: Incompatible types in assignment (expression has type "BufferedWriter[_BufferedWriterStream]", variable has type "_TemporaryFileWrapper[bytes]")  [assignment]

github-actions[bot] avatar May 22 '25 11:05 github-actions[bot]

Diff from mypy_primer, showing the effect of this PR on open source code:

zope.interface (https://github.com/zopefoundation/zope.interface)
- src/zope/interface/common/tests/test_io.py:36: error: Argument 1 to "BufferedWriter" has incompatible type "StringIO"; expected "RawIOBase"  [arg-type]
+ src/zope/interface/common/tests/test_io.py:36: error: Value of type variable "_BufferedWriterStreamT" of "BufferedWriter" cannot be "StringIO"  [type-var]
- src/zope/interface/common/tests/test_io.py:41: error: Argument 2 to "BufferedRWPair" has incompatible type "BytesIO"; expected "RawIOBase"  [arg-type]

ibis (https://github.com/ibis-project/ibis)
- ibis/expr/visualize.py:182: error: Incompatible types in assignment (expression has type "BufferedWriter", variable has type "_TemporaryFileWrapper[bytes]")  [assignment]
+ ibis/expr/visualize.py:182: error: Incompatible types in assignment (expression has type "BufferedWriter[_BufferedWriterStream]", variable has type "_TemporaryFileWrapper[bytes]")  [assignment]

github-actions[bot] avatar Jul 26 '25 04:07 github-actions[bot]

Diff from mypy_primer, showing the effect of this PR on open source code:

zope.interface (https://github.com/zopefoundation/zope.interface)
- src/zope/interface/common/tests/test_io.py:36: error: Argument 1 to "BufferedWriter" has incompatible type "StringIO"; expected "RawIOBase"  [arg-type]
+ src/zope/interface/common/tests/test_io.py:36: error: Value of type variable "_BufferedWriterStreamT" of "BufferedWriter" cannot be "StringIO"  [type-var]
- src/zope/interface/common/tests/test_io.py:41: error: Argument 2 to "BufferedRWPair" has incompatible type "BytesIO"; expected "RawIOBase"  [arg-type]

ibis (https://github.com/ibis-project/ibis)
- ibis/expr/visualize.py:182: error: Incompatible types in assignment (expression has type "BufferedWriter", variable has type "_TemporaryFileWrapper[bytes]")  [assignment]
+ ibis/expr/visualize.py:182: error: Incompatible types in assignment (expression has type "BufferedWriter[_BufferedWriterStream]", variable has type "_TemporaryFileWrapper[bytes]")  [assignment]

github-actions[bot] avatar Nov 05 '25 10:11 github-actions[bot]