66 IOBase ,
77 UnsupportedOperation ,
88)
9- from typing import IO , Generic , Optional , TypeVar , Union , cast
9+ from typing import BinaryIO , Generic , Optional , TypeVar , Union , cast
1010
1111from xz .utils import FloorDict
1212
1313#
1414# Typing note
1515#
1616# The consensus seems to favour IO instead of IOBase for typing.
17- # However we cannot subclass IO[bytes] in IOAbstract as it conflicts with IOBase.
17+ # However we cannot subclass BinaryIO in IOAbstract as it conflicts with IOBase.
1818#
19- # As a result, some casting or unions between IOAbstract and IO[bytes] may be required internally.
19+ # As a result, some casting or unions between the two types may be required internally.
2020#
2121
2222
@@ -41,7 +41,7 @@ def _check_not_closed(self) -> None:
4141
4242 def fileno (self ) -> int :
4343 try :
44- return cast (IO [ bytes ] , self .fileobj ).fileno () # type: ignore[attr-defined]
44+ return cast (BinaryIO , self .fileobj ).fileno () # type: ignore[attr-defined]
4545 except AttributeError :
4646 raise UnsupportedOperation ("fileno" ) # pylint: disable=raise-missing-from
4747
@@ -245,7 +245,7 @@ def _read(self, size: int) -> bytes:
245245class IOProxy (IOAbstract ):
246246 def __init__ (
247247 self ,
248- fileobj : Union [IO [ bytes ], IOAbstract ], # see typing note on top of this file
248+ fileobj : Union [BinaryIO , IOBase ], # see typing note on top of this file
249249 start : int ,
250250 end : int ,
251251 ) -> None :
0 commit comments