diff --git a/stdlib/2and3/mmap.pyi b/stdlib/2and3/mmap.pyi index f977d82a469b..22d92b19ab0f 100644 --- a/stdlib/2and3/mmap.pyi +++ b/stdlib/2and3/mmap.pyi @@ -1,6 +1,7 @@ import sys from typing import (Optional, Sequence, Union, Generic, overload, Iterable, Iterator, Sized, ContextManager, AnyStr) +from _typeshed import ReadableBuffer ACCESS_DEFAULT: int ACCESS_READ: int @@ -40,14 +41,20 @@ class _mmap(Generic[AnyStr]): else: def flush(self, offset: int = ..., size: int = ...) -> int: ... def move(self, dest: int, src: int, count: int) -> None: ... - def read(self, n: int = ...) -> AnyStr: ... + if sys.version_info >= (3, 3): + def read(self, n: int = ...) -> AnyStr: ... + else: + def read(self, n: int) -> AnyStr: ... def read_byte(self) -> AnyStr: ... def readline(self) -> AnyStr: ... def resize(self, newsize: int) -> None: ... def seek(self, pos: int, whence: int = ...) -> None: ... def size(self) -> int: ... def tell(self) -> int: ... - def write(self, bytes: AnyStr) -> None: ... + if sys.version_info >= (3, 6): + def write(self, bytes: AnyStr) -> int: ... + else: + def write(self, bytes: AnyStr) -> None: ... def write_byte(self, byte: AnyStr) -> None: ... def __len__(self) -> int: ... @@ -56,7 +63,15 @@ if sys.version_info >= (3,): closed: bool if sys.version_info >= (3, 8) and sys.platform != "win32": def madvise(self, option: int, start: int = ..., length: int = ...) -> None: ... - def rfind(self, sub: bytes, start: int = ..., stop: int = ...) -> int: ... + if sys.version_info >= (3, 5): + def find(self, sub: ReadableBuffer, start: int = ..., stop: int = ...) -> int: ... + def rfind(self, sub: ReadableBuffer, start: int = ..., stop: int = ...) -> int: ... + else: + def rfind(self, sub: bytes, start: int = ..., stop: int = ...) -> int: ... + if sys.version_info >= (3, 6): + def write(self, bytes: ReadableBuffer) -> int: ... + elif sys.version_info >= (3, 5): + def write(self, bytes: ReadableBuffer) -> None: ... @overload def __getitem__(self, index: int) -> int: ... @overload