This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author conchylicultor
Recipients conchylicultor
Date 2020-11-30.11:17:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Currently, because `BinaryIO` is subclass of `IO[bytes]`, the 2 cannot be used interchangeably.

Example with pytype:

def iter_zip(arch_f) -> List[typing.BinaryIO]]:
  with open(arch_f, 'rb') as fobj:
    z = zipfile.ZipFile(fobj)
    return [ for member in z.infolist()]


           Expected: Tuple[str, BinaryIO]
  Actually returned: Tuple[Any, IO[bytes]]

Technically pytype is right as ` -> IO[bytes]`:

But this makes BinaryIO usage quite confusing.

From the implementation, it seems that the BinaryIO is slightly different (

But the documentation is unclear about the difference between the 2

Additionally, `typing.IO` is implemented as Generic but shouldn't this be a Protocol instead ?
Date User Action Args
2020-11-30 11:17:54conchylicultorsetrecipients: + conchylicultor
2020-11-30 11:17:54conchylicultorsetmessageid: <>
2020-11-30 11:17:54conchylicultorlinkissue42512 messages
2020-11-30 11:17:53conchylicultorcreate