Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions stdlib/2and3/mmap.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from typing import (Optional, Sequence, Union, Generic, overload,
Iterable, Iterator, Sized, ContextManager, AnyStr)
from typing import (Optional, Union, Generic, overload, Iterable,
Iterator, Sized, ContextManager, AnyStr)

ACCESS_DEFAULT: int
ACCESS_READ: int
Expand Down Expand Up @@ -49,7 +49,10 @@ class _mmap(Generic[AnyStr]):
def __len__(self) -> int: ...

if sys.version_info >= (3,):
class mmap(_mmap[bytes], ContextManager[mmap], Iterable[bytes], Sized):
# Inherit both `bytearray` and `Iterable[bytes]` because mmap can be used
# in places where bytearray is expected, like re.match, while iterating
# through `mmap` yields `bytes` objects, not integers.
class mmap(_mmap[bytes], ContextManager[mmap], bytearray, Iterable[bytes], Sized):
closed: bool
def rfind(self, sub: bytes, start: int = ..., stop: int = ...) -> int: ...
@overload
Expand All @@ -65,7 +68,7 @@ if sys.version_info >= (3,):
# __len__, so we claim that there is also an __iter__ to help type checkers.
def __iter__(self) -> Iterator[bytes]: ...
else:
class mmap(_mmap[bytes], Sequence[bytes]):
class mmap(_mmap[bytes], bytes):
def rfind(self, string: bytes, start: int = ..., stop: int = ...) -> int: ...
def __getitem__(self, index: Union[int, slice]) -> bytes: ...
def __getslice__(self, i: Optional[int], j: Optional[int]) -> bytes: ...
Expand Down