stdlib: Add bytes defaults (#9660)

This commit is contained in:
Alex Waygood
2023-02-03 00:01:54 +00:00
committed by GitHub
parent f1aede7162
commit 100cd62373
8 changed files with 34 additions and 34 deletions

View File

@@ -163,7 +163,7 @@ class StreamReader(AsyncIterator[bytes]):
def feed_data(self, data: Iterable[SupportsIndex]) -> None: ...
async def readline(self) -> bytes: ...
# Can be any buffer that supports len(); consider changing to a Protocol if PEP 688 is accepted
async def readuntil(self, separator: bytes | bytearray | memoryview = ...) -> bytes: ...
async def readuntil(self, separator: bytes | bytearray | memoryview = b"\n") -> bytes: ...
async def read(self, n: int = -1) -> bytes: ...
async def readexactly(self, n: int) -> bytes: ...
def __aiter__(self: Self) -> Self: ...

View File

@@ -45,7 +45,7 @@ def a85encode(
b: ReadableBuffer, *, foldspaces: bool = False, wrapcol: int = 0, pad: bool = False, adobe: bool = False
) -> bytes: ...
def a85decode(
b: str | ReadableBuffer, *, foldspaces: bool = False, adobe: bool = False, ignorechars: bytearray | bytes = ...
b: str | ReadableBuffer, *, foldspaces: bool = False, adobe: bool = False, ignorechars: bytearray | bytes = b" \t\n\r\x0b"
) -> bytes: ...
def b85encode(b: ReadableBuffer, pad: bool = False) -> bytes: ...
def b85decode(b: str | ReadableBuffer) -> bytes: ...

View File

@@ -595,7 +595,7 @@ class bytes(ByteString):
@overload
def __new__(cls: type[Self]) -> Self: ...
def capitalize(self) -> bytes: ...
def center(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytes: ...
def center(self, __width: SupportsIndex, __fillchar: bytes = b" ") -> bytes: ...
def count(
self, __sub: ReadableBuffer | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
) -> int: ...
@@ -631,7 +631,7 @@ class bytes(ByteString):
def istitle(self) -> bool: ...
def isupper(self) -> bool: ...
def join(self, __iterable_of_bytes: Iterable[ReadableBuffer]) -> bytes: ...
def ljust(self, __width: SupportsIndex, __fillchar: bytes | bytearray = ...) -> bytes: ...
def ljust(self, __width: SupportsIndex, __fillchar: bytes | bytearray = b" ") -> bytes: ...
def lower(self) -> bytes: ...
def lstrip(self, __bytes: ReadableBuffer | None = None) -> bytes: ...
def partition(self, __sep: ReadableBuffer) -> tuple[bytes, bytes, bytes]: ...
@@ -646,7 +646,7 @@ class bytes(ByteString):
def rindex(
self, __sub: ReadableBuffer | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
) -> int: ...
def rjust(self, __width: SupportsIndex, __fillchar: bytes | bytearray = ...) -> bytes: ...
def rjust(self, __width: SupportsIndex, __fillchar: bytes | bytearray = b" ") -> bytes: ...
def rpartition(self, __sep: ReadableBuffer) -> tuple[bytes, bytes, bytes]: ...
def rsplit(self, sep: ReadableBuffer | None = None, maxsplit: SupportsIndex = -1) -> list[bytes]: ...
def rstrip(self, __bytes: ReadableBuffer | None = None) -> bytes: ...
@@ -661,7 +661,7 @@ class bytes(ByteString):
def strip(self, __bytes: ReadableBuffer | None = None) -> bytes: ...
def swapcase(self) -> bytes: ...
def title(self) -> bytes: ...
def translate(self, __table: ReadableBuffer | None, delete: bytes = ...) -> bytes: ...
def translate(self, __table: ReadableBuffer | None, delete: bytes = b"") -> bytes: ...
def upper(self) -> bytes: ...
def zfill(self, __width: SupportsIndex) -> bytes: ...
@classmethod
@@ -699,7 +699,7 @@ class bytearray(MutableSequence[int], ByteString):
def __init__(self, __string: str, encoding: str, errors: str = ...) -> None: ...
def append(self, __item: SupportsIndex) -> None: ...
def capitalize(self) -> bytearray: ...
def center(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytearray: ...
def center(self, __width: SupportsIndex, __fillchar: bytes = b" ") -> bytearray: ...
def count(
self, __sub: ReadableBuffer | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
) -> int: ...
@@ -738,7 +738,7 @@ class bytearray(MutableSequence[int], ByteString):
def istitle(self) -> bool: ...
def isupper(self) -> bool: ...
def join(self, __iterable_of_bytes: Iterable[ReadableBuffer]) -> bytearray: ...
def ljust(self, __width: SupportsIndex, __fillchar: bytes | bytearray = ...) -> bytearray: ...
def ljust(self, __width: SupportsIndex, __fillchar: bytes | bytearray = b" ") -> bytearray: ...
def lower(self) -> bytearray: ...
def lstrip(self, __bytes: ReadableBuffer | None = None) -> bytearray: ...
def partition(self, __sep: ReadableBuffer) -> tuple[bytearray, bytearray, bytearray]: ...
@@ -755,7 +755,7 @@ class bytearray(MutableSequence[int], ByteString):
def rindex(
self, __sub: ReadableBuffer | SupportsIndex, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ...
) -> int: ...
def rjust(self, __width: SupportsIndex, __fillchar: bytes | bytearray = ...) -> bytearray: ...
def rjust(self, __width: SupportsIndex, __fillchar: bytes | bytearray = b" ") -> bytearray: ...
def rpartition(self, __sep: ReadableBuffer) -> tuple[bytearray, bytearray, bytearray]: ...
def rsplit(self, sep: ReadableBuffer | None = None, maxsplit: SupportsIndex = -1) -> list[bytearray]: ...
def rstrip(self, __bytes: ReadableBuffer | None = None) -> bytearray: ...
@@ -770,7 +770,7 @@ class bytearray(MutableSequence[int], ByteString):
def strip(self, __bytes: ReadableBuffer | None = None) -> bytearray: ...
def swapcase(self) -> bytearray: ...
def title(self) -> bytearray: ...
def translate(self, __table: ReadableBuffer | None, delete: bytes = ...) -> bytearray: ...
def translate(self, __table: ReadableBuffer | None, delete: bytes = b"") -> bytearray: ...
def upper(self) -> bytearray: ...
def zfill(self, __width: SupportsIndex) -> bytearray: ...
@classmethod

View File

@@ -95,7 +95,7 @@ class FieldStorage:
self,
fp: IO[Any] | None = None,
headers: Mapping[str, str] | Message | None = None,
outerboundary: bytes = ...,
outerboundary: bytes = b"",
environ: SupportsGetItem[str, str] = ...,
keep_blank_values: int = 0,
strict_parsing: int = 0,

View File

@@ -132,10 +132,10 @@ def diff_bytes(
dfunc: Callable[[Sequence[str], Sequence[str], str, str, str, str, int, str], Iterator[str]],
a: Iterable[bytes | bytearray],
b: Iterable[bytes | bytearray],
fromfile: bytes | bytearray = ...,
tofile: bytes | bytearray = ...,
fromfiledate: bytes | bytearray = ...,
tofiledate: bytes | bytearray = ...,
fromfile: bytes | bytearray = b"",
tofile: bytes | bytearray = b"",
fromfiledate: bytes | bytearray = b"",
tofiledate: bytes | bytearray = b"",
n: int = 3,
lineterm: bytes | bytearray = ...,
lineterm: bytes | bytearray = b"\n",
) -> Iterator[bytes]: ...

View File

@@ -79,9 +79,9 @@ def open(
class _PaddedFile:
file: _ReadableFileobj
def __init__(self, f: _ReadableFileobj, prepend: bytes = ...) -> None: ...
def __init__(self, f: _ReadableFileobj, prepend: bytes = b"") -> None: ...
def read(self, size: int) -> bytes: ...
def prepend(self, prepend: bytes = ...) -> None: ...
def prepend(self, prepend: bytes = b"") -> None: ...
def seek(self, off: int) -> int: ...
def seekable(self) -> bool: ...

View File

@@ -62,25 +62,25 @@ class _Hash:
def update(self, __data: ReadableBuffer) -> None: ...
if sys.version_info >= (3, 9):
def new(name: str, data: ReadableBuffer = ..., *, usedforsecurity: bool = ...) -> _Hash: ...
def md5(string: ReadableBuffer = ..., *, usedforsecurity: bool = True) -> _Hash: ...
def sha1(string: ReadableBuffer = ..., *, usedforsecurity: bool = True) -> _Hash: ...
def sha224(string: ReadableBuffer = ..., *, usedforsecurity: bool = True) -> _Hash: ...
def sha256(string: ReadableBuffer = ..., *, usedforsecurity: bool = True) -> _Hash: ...
def sha384(string: ReadableBuffer = ..., *, usedforsecurity: bool = True) -> _Hash: ...
def sha512(string: ReadableBuffer = ..., *, usedforsecurity: bool = True) -> _Hash: ...
def new(name: str, data: ReadableBuffer = b"", *, usedforsecurity: bool = ...) -> _Hash: ...
def md5(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> _Hash: ...
def sha1(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> _Hash: ...
def sha224(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> _Hash: ...
def sha256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> _Hash: ...
def sha384(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> _Hash: ...
def sha512(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> _Hash: ...
elif sys.version_info >= (3, 8):
def new(name: str, data: ReadableBuffer = ...) -> _Hash: ...
def md5(string: ReadableBuffer = ...) -> _Hash: ...
def sha1(string: ReadableBuffer = ...) -> _Hash: ...
def sha224(string: ReadableBuffer = ...) -> _Hash: ...
def sha256(string: ReadableBuffer = ...) -> _Hash: ...
def sha384(string: ReadableBuffer = ...) -> _Hash: ...
def sha512(string: ReadableBuffer = ...) -> _Hash: ...
def new(name: str, data: ReadableBuffer = b"") -> _Hash: ...
def md5(string: ReadableBuffer = b"") -> _Hash: ...
def sha1(string: ReadableBuffer = b"") -> _Hash: ...
def sha224(string: ReadableBuffer = b"") -> _Hash: ...
def sha256(string: ReadableBuffer = b"") -> _Hash: ...
def sha384(string: ReadableBuffer = b"") -> _Hash: ...
def sha512(string: ReadableBuffer = b"") -> _Hash: ...
else:
def new(name: str, data: ReadableBuffer = ...) -> _Hash: ...
def new(name: str, data: ReadableBuffer = b"") -> _Hash: ...
def md5(__string: ReadableBuffer = ...) -> _Hash: ...
def sha1(__string: ReadableBuffer = ...) -> _Hash: ...
def sha224(__string: ReadableBuffer = ...) -> _Hash: ...

View File

@@ -53,4 +53,4 @@ def compressobj(
) -> _Compress: ...
def crc32(__data: ReadableBuffer, __value: int = 0) -> int: ...
def decompress(__data: ReadableBuffer, wbits: int = 15, bufsize: int = 16384) -> bytes: ...
def decompressobj(wbits: int = 15, zdict: ReadableBuffer = ...) -> _Decompress: ...
def decompressobj(wbits: int = 15, zdict: ReadableBuffer = b"") -> _Decompress: ...