When opening a file with binary mode, typing.BinaryIO is inferred.
This type should have the https://docs.python.org/3/library/io.html#io.BufferedReader.peek method.
It looks like this is known, judging by the TODO on this line in the typing.pyi stub:
(There are also other
TODOs there for BinaryIO - if those should be added, I could of course do those in the same change if that's not a problem.)
A reproducible example:
with open("some-file", 'rb') as f:
f.peek()
Running mypy on this results in error: "BinaryIO" has no attribute "peek".
This issue has also been reported earlier in mypy.
I'd be glad to submit a PR for this. Is it as simple as adding peek to BinaryIO in typing.pyi? Or should there also be tests for these changes?