JelleZijlstra / stubdefaulter

Add default values to stubs
Other
10 stars 4 forks source link

Add `bytes` default values #49

Closed AlexWaygood closed 1 year ago

github-actions[bot] commented 1 year ago

⚠ Diff showing the effect of this PR on how stubdefaulter would alter typeshed's stdlib:

```diff diff --git a/stdlib/asyncio/streams.pyi b/stdlib/asyncio/streams.pyi index c09c102..4a093d7 100644 --- a/stdlib/asyncio/streams.pyi +++ b/stdlib/asyncio/streams.pyi @@ -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: ... diff --git a/stdlib/base64.pyi b/stdlib/base64.pyi index 9a69645..7c6cdcf 100644 --- a/stdlib/base64.pyi +++ b/stdlib/base64.pyi @@ -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: ... diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 173a531..abbeb61 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -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 diff --git a/stdlib/cgi.pyi b/stdlib/cgi.pyi index 4780969..48c334a 100644 --- a/stdlib/cgi.pyi +++ b/stdlib/cgi.pyi @@ -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, diff --git a/stdlib/difflib.pyi b/stdlib/difflib.pyi index b8efcaf..7e6a6ae 100644 --- a/stdlib/difflib.pyi +++ b/stdlib/difflib.pyi @@ -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]: ... diff --git a/stdlib/gzip.pyi b/stdlib/gzip.pyi index 36f9103..c749036 100644 --- a/stdlib/gzip.pyi +++ b/stdlib/gzip.pyi @@ -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: ... diff --git a/stdlib/hashlib.pyi b/stdlib/hashlib.pyi index 13d3e2f..d7e82e3 100644 --- a/stdlib/hashlib.pyi +++ b/stdlib/hashlib.pyi @@ -62,13 +62,13 @@ 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: ... diff --git a/stdlib/zlib.pyi b/stdlib/zlib.pyi index 6b4bf26..1a5be57 100644 --- a/stdlib/zlib.pyi +++ b/stdlib/zlib.pyi @@ -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: ... ```