diff --git a/rohmu/util.py b/rohmu/util.py index 7738de4c..0ec1790e 100644 --- a/rohmu/util.py +++ b/rohmu/util.py @@ -5,12 +5,16 @@ See LICENSE for details """ from __future__ import annotations - +import sys from io import BytesIO, UnsupportedOperation from itertools import islice from rohmu.typing import HasFileno from typing import BinaryIO, Generator, Iterable, Optional, Tuple, TypeVar, Union -from typing_extensions import Buffer +if sys.version_info < (3, 10): + from typing_extensions import Buffer +else: + from typing import ByteString, MutableSequence + Buffer = Union[ByteString, MutableSequence[bytes]] import fcntl import logging @@ -205,10 +209,10 @@ def seek(self, offset: int, whence: int = 0) -> int: def truncate(self, size: Optional[int] = None) -> int: raise UnsupportedOperation("truncate") - def write(self, s: Union[bytes, Buffer]) -> int: + def write(self, s: Union[bytes, Buffer]) -> int: # type: ignore raise UnsupportedOperation("write") - def writelines(self, __lines: Union[Iterable[bytes], Iterable[Buffer]]) -> None: + def writelines(self, __lines: Union[Iterable[bytes], Iterable[Buffer]]) -> None: # type: ignore raise UnsupportedOperation("writelines") def fileno(self) -> int: