@@ -49,7 +49,10 @@ class _mmap(Generic[AnyStr]):
49
49
def __len__ (self ) -> int : ...
50
50
51
51
if sys .version_info >= (3 ,):
52
- class mmap (_mmap , ContextManager [mmap ], Iterable [bytes ], Sized ):
52
+ # Inherit both `bytearray` and `Iterable[bytes]` because mmap can be used
53
+ # in places where bytearray is expected, like re.match, while iterating
54
+ # through `mmap` yields `bytes` objects, not integers.
55
+ class mmap (_mmap , ContextManager [mmap ], bytearray , Iterable [bytes ], Sized ):
53
56
closed : bool
54
57
def rfind (self , sub : bytes , start : int = ..., stop : int = ...) -> int : ...
55
58
@overload
@@ -65,7 +68,7 @@ if sys.version_info >= (3,):
65
68
# __len__, so we claim that there is also an __iter__ to help type checkers.
66
69
def __iter__ (self ) -> Iterator [bytes ]: ...
67
70
else :
68
- class mmap (_mmap , Sequence [ bytes ] ):
71
+ class mmap (_mmap , bytes ):
69
72
def rfind (self , string : bytes , start : int = ..., stop : int = ...) -> int : ...
70
73
def __getitem__ (self , index : Union [int , slice ]) -> bytes : ...
71
74
def __getslice__ (self , i : Optional [int ], j : Optional [int ]) -> bytes : ...
0 commit comments