[alt] typing: accept buffers in IO.write#9861
Conversation
Co-authored-by: JelleZijlstra <jelle.zijlstra@gmail.com>
| @overload | ||
| def write(self, s: AnyStr) -> int: ... |
There was a problem hiding this comment.
Is the third overload needed? This should be covered by the preceding two overloads. (Same for further overloads below.)
There was a problem hiding this comment.
Unfortunately the test cases I've added don't pass for pyright unless we include this third overload. This is due to a design decision by pyright in the way it handles contrained TypeVars that leads to different behaviour from mypy: https://github.com/microsoft/pyright/blob/main/docs/mypy-comparison.md#constrained-type-variables
It's the same issue that led to microsoft/pyright#4534 being filed, which we then fixed over at typeshed in #9592.
|
Diff from mypy_primer, showing the effect of this PR on open source code: |
Two errors go away ( |
An alternative PR to #9084 (closes #9084)
Fixes #9082
Co-authored-by: JelleZijlstra jelle.zijlstra@gmail.com