Skip to content

Commit

Permalink
make Buffer compatible with python 3.10 and above
Browse files Browse the repository at this point in the history
  • Loading branch information
Aiqin-Aiven committed Sep 20, 2023
1 parent 1769e1b commit 30242fe
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions rohmu/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 30242fe

Please sign in to comment.