mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +08:00
Add memoryview class for python 2.7 (#493)
This commit is contained in:
committed by
Matthias Kramm
parent
aef68f323f
commit
ed7c0779f7
@@ -8,7 +8,7 @@ from typing import (
|
||||
Sequence, Mapping, Tuple, List, Any, Dict, Callable, Generic, Set,
|
||||
AbstractSet, Sized, Reversible, SupportsInt, SupportsFloat, SupportsAbs,
|
||||
SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping,
|
||||
MutableSet, ItemsView, KeysView, ValuesView
|
||||
MutableSet, ItemsView, KeysView, ValuesView, Optional, Container,
|
||||
)
|
||||
from abc import abstractmethod, ABCMeta
|
||||
|
||||
@@ -705,7 +705,6 @@ def map(func: Callable[[_T1, _T2], _S],
|
||||
def max(arg1: _T, arg2: _T, *args: _T, key: Callable[[_T], Any] = None) -> _T: ...
|
||||
@overload
|
||||
def max(iterable: Iterable[_T], key: Callable[[_T], Any] = None) -> _T: ...
|
||||
# TODO memoryview
|
||||
@overload
|
||||
def min(arg1: _T, arg2: _T, *args: _T, key: Callable[[_T], Any] = None) -> _T: ...
|
||||
@overload
|
||||
@@ -801,6 +800,36 @@ class buffer(Sized):
|
||||
def __len__(self) -> int: ...
|
||||
def __mul__(self, x: int) -> str: ...
|
||||
|
||||
class memoryview(Sized, Container[bytes]):
|
||||
format = ... # type: str
|
||||
itemsize = ... # type: int
|
||||
shape = ... # type: Optional[Tuple[int, ...]]
|
||||
strides = ... # type: Optional[Tuple[int, ...]]
|
||||
suboffsets = ... # type: Optional[Tuple[int, ...]]
|
||||
readonly = ... # type: bool
|
||||
ndim = ... # type: int
|
||||
|
||||
def __init__(self, obj: Union[str, bytearray, buffer, memoryview]) -> None: ...
|
||||
|
||||
@overload
|
||||
def __getitem__(self, i: int) -> bytes: ...
|
||||
@overload
|
||||
def __getitem__(self, s: slice) -> memoryview: ...
|
||||
|
||||
def __contains__(self, x: object) -> bool: ...
|
||||
def __iter__(self) -> Iterator[bytes]: ...
|
||||
def __len__(self) -> int: ...
|
||||
|
||||
@overload
|
||||
def __setitem__(self, i: int, o: bytes) -> None: ...
|
||||
@overload
|
||||
def __setitem__(self, s: slice, o: Sequence[bytes]) -> None: ...
|
||||
@overload
|
||||
def __setitem__(self, s: slice, o: memoryview) -> None: ...
|
||||
|
||||
def tobytes(self) -> bytes: ...
|
||||
def tolist(self) -> List[int]: ...
|
||||
|
||||
class BaseException:
|
||||
args = ... # type: Any
|
||||
message = ... # type: str
|
||||
|
||||
Reference in New Issue
Block a user