Update count, (r)find, and (r)index type hints for bytes and bytearray (#923)

The above methods have changed in version 3.3 to also accept an integer in
the range 0 to 255 as the subsequence.

Fixes python/mypy#2831
This commit is contained in:
5j9
2017-02-09 02:51:41 +03:30
committed by Guido van Rossum
parent 65b45282f4
commit f192b8c784

View File

@@ -299,14 +299,23 @@ class bytes(ByteString):
def __init__(self, o: SupportsBytes) -> None: ...
def capitalize(self) -> bytes: ...
def center(self, width: int, fillchar: bytes = ...) -> bytes: ...
def count(self, x: bytes) -> int: ...
if sys.version_info >= (3, 3):
def count(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ...
else:
def count(self, sub: bytes, start: int = None, end: int = None) -> int: ...
def decode(self, encoding: str = 'utf-8', errors: str = 'strict') -> str: ...
def endswith(self, suffix: Union[bytes, Tuple[bytes, ...]]) -> bool: ...
def expandtabs(self, tabsize: int = 8) -> bytes: ...
def find(self, sub: bytes, start: int = 0, end: int = 0) -> int: ...
if sys.version_info >= (3, 3):
def find(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ...
else:
def find(self, sub: bytes, start: int = None, end: int = None) -> int: ...
if sys.version_info >= (3, 5):
def hex(self) -> str: ...
def index(self, sub: bytes, start: int = 0, end: int = 0) -> int: ...
if sys.version_info >= (3, 3):
def index(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ...
else:
def index(self, sub: bytes, start: int = None, end: int = None) -> int: ...
def isalnum(self) -> bool: ...
def isalpha(self) -> bool: ...
def isdigit(self) -> bool: ...
@@ -320,8 +329,14 @@ class bytes(ByteString):
def lstrip(self, chars: bytes = None) -> bytes: ...
def partition(self, sep: bytes) -> Tuple[bytes, bytes, bytes]: ...
def replace(self, old: bytes, new: bytes, count: int = -1) -> bytes: ...
def rfind(self, sub: bytes, start: int = 0, end: int = 0) -> int: ...
def rindex(self, sub: bytes, start: int = 0, end: int = 0) -> int: ...
if sys.version_info >= (3, 3):
def rfind(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ...
else:
def rfind(self, sub: bytes, start: int = None, end: int = None) -> int: ...
if sys.version_info >= (3, 3):
def rindex(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ...
else:
def rindex(self, sub: bytes, start: int = None, end: int = None) -> int: ...
def rjust(self, width: int, fillchar: bytes = ...) -> bytes: ...
def rpartition(self, sep: bytes) -> Tuple[bytes, bytes, bytes]: ...
def rsplit(self, sep: bytes = None, maxsplit: int = -1) -> List[bytes]: ...
@@ -373,14 +388,23 @@ class bytearray(MutableSequence[int], ByteString):
def __init__(self) -> None: ...
def capitalize(self) -> bytearray: ...
def center(self, width: int, fillchar: bytes = ...) -> bytearray: ...
def count(self, x: bytes) -> int: ...
if sys.version_info >= (3, 3):
def count(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ...
else:
def count(self, sub: bytes, start: int = None, end: int = None) -> int: ...
def decode(self, encoding: str = 'utf-8', errors: str = 'strict') -> str: ...
def endswith(self, suffix: bytes) -> bool: ...
def expandtabs(self, tabsize: int = 8) -> bytearray: ...
def find(self, sub: bytes, start: int = 0, end: int = 0) -> int: ...
if sys.version_info >= (3, 3):
def find(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ...
else:
def find(self, sub: bytes, start: int = None, end: int = None) -> int: ...
if sys.version_info >= (3, 5):
def hex(self) -> str: ...
def index(self, sub: bytes, start: int = 0, end: int = 0) -> int: ...
if sys.version_info >= (3, 3):
def index(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ...
else:
def index(self, sub: bytes, start: int = None, end: int = None) -> int: ...
def insert(self, index: int, object: int) -> None: ...
def isalnum(self) -> bool: ...
def isalpha(self) -> bool: ...
@@ -395,8 +419,14 @@ class bytearray(MutableSequence[int], ByteString):
def lstrip(self, chars: bytes = None) -> bytearray: ...
def partition(self, sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ...
def replace(self, old: bytes, new: bytes, count: int = -1) -> bytearray: ...
def rfind(self, sub: bytes, start: int = 0, end: int = 0) -> int: ...
def rindex(self, sub: bytes, start: int = 0, end: int = 0) -> int: ...
if sys.version_info >= (3, 3):
def rfind(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ...
else:
def rfind(self, sub: bytes, start: int = None, end: int = None) -> int: ...
if sys.version_info >= (3, 3):
def rindex(self, sub: Union[bytes, int], start: int = None, end: int = None) -> int: ...
else:
def rindex(self, sub: bytes, start: int = None, end: int = None) -> int: ...
def rjust(self, width: int, fillchar: bytes = ...) -> bytearray: ...
def rpartition(self, sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ...
def rsplit(self, sep: bytes = None, maxsplit: int = -1) -> List[bytearray]: ...