Previously typing.IO
, typing.TextIO
, and typing.BinaryIO
were available to annotate file-like objects, e.g. those returned by open()
. However, after Python 3.8 they seem to be deprecated, and will be removed in Python 3.12. Unlike many of the other deprecations like typing.List[T]
, which is replaced by list[T]
, these IO types have no clear migration path.
How should file-like object types be annotated in modern Python, going forward?