From d98d1674e7bfb385153e7f1c24bcd66bf20ca860 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 20 Jan 2023 17:47:59 +0000 Subject: [PATCH] Fix a few issues with parameter defaults (#9572) --- stdlib/asyncore.pyi | 2 +- stdlib/collections/__init__.pyi | 14 +++++++------- stdlib/ctypes/__init__.pyi | 2 +- stdlib/email/parser.pyi | 8 ++++++-- stdlib/multiprocessing/heap.pyi | 2 +- stdlib/platform.pyi | 4 +--- stdlib/pydoc.pyi | 2 +- stdlib/socket.pyi | 7 ++++++- stdlib/ssl.pyi | 22 +++++++++++----------- stdlib/sysconfig.pyi | 4 ++-- 10 files changed, 37 insertions(+), 30 deletions(-) diff --git a/stdlib/asyncore.pyi b/stdlib/asyncore.pyi index 9c91ddaf2..667f50ad4 100644 --- a/stdlib/asyncore.pyi +++ b/stdlib/asyncore.pyi @@ -36,7 +36,7 @@ class dispatcher: def __init__(self, sock: _Socket | None = None, map: _MapType | None = None) -> None: ... def add_channel(self, map: _MapType | None = None) -> None: ... def del_channel(self, map: _MapType | None = None) -> None: ... - def create_socket(self, family: int = 2, type: int = 1) -> None: ... + def create_socket(self, family: int = ..., type: int = ...) -> None: ... def set_socket(self, sock: _Socket, map: _MapType | None = None) -> None: ... def set_reuse_addr(self) -> None: ... def readable(self) -> bool: ... diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index f524293af..63380af3f 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -163,18 +163,18 @@ class UserString(Sequence[UserString]): def capitalize(self: Self) -> Self: ... def casefold(self: Self) -> Self: ... def center(self: Self, width: int, *args: Any) -> Self: ... - def count(self, sub: str | UserString, start: int = 0, end: int = 9223372036854775807) -> int: ... + def count(self, sub: str | UserString, start: int = 0, end: int = ...) -> int: ... if sys.version_info >= (3, 8): def encode(self: UserString, encoding: str | None = "utf-8", errors: str | None = "strict") -> bytes: ... else: def encode(self: Self, encoding: str | None = ..., errors: str | None = ...) -> Self: ... - def endswith(self, suffix: str | tuple[str, ...], start: int | None = 0, end: int | None = 9223372036854775807) -> bool: ... + def endswith(self, suffix: str | tuple[str, ...], start: int | None = 0, end: int | None = ...) -> bool: ... def expandtabs(self: Self, tabsize: int = 8) -> Self: ... - def find(self, sub: str | UserString, start: int = 0, end: int = 9223372036854775807) -> int: ... + def find(self, sub: str | UserString, start: int = 0, end: int = ...) -> int: ... def format(self, *args: Any, **kwds: Any) -> str: ... def format_map(self, mapping: Mapping[str, Any]) -> str: ... - def index(self, sub: str, start: int = 0, end: int = 9223372036854775807) -> int: ... + def index(self, sub: str, start: int = 0, end: int = ...) -> int: ... def isalpha(self) -> bool: ... def isalnum(self) -> bool: ... def isdecimal(self) -> bool: ... @@ -203,15 +203,15 @@ class UserString(Sequence[UserString]): def removesuffix(self: Self, __suffix: str | UserString) -> Self: ... def replace(self: Self, old: str | UserString, new: str | UserString, maxsplit: int = -1) -> Self: ... - def rfind(self, sub: str | UserString, start: int = 0, end: int = 9223372036854775807) -> int: ... - def rindex(self, sub: str | UserString, start: int = 0, end: int = 9223372036854775807) -> int: ... + def rfind(self, sub: str | UserString, start: int = 0, end: int = ...) -> int: ... + def rindex(self, sub: str | UserString, start: int = 0, end: int = ...) -> int: ... def rjust(self: Self, width: int, *args: Any) -> Self: ... def rpartition(self, sep: str) -> tuple[str, str, str]: ... def rstrip(self: Self, chars: str | None = None) -> Self: ... def split(self, sep: str | None = None, maxsplit: int = -1) -> list[str]: ... def rsplit(self, sep: str | None = None, maxsplit: int = -1) -> list[str]: ... def splitlines(self, keepends: bool = False) -> list[str]: ... - def startswith(self, prefix: str | tuple[str, ...], start: int | None = 0, end: int | None = 9223372036854775807) -> bool: ... + def startswith(self, prefix: str | tuple[str, ...], start: int | None = 0, end: int | None = ...) -> bool: ... def strip(self: Self, chars: str | None = None) -> Self: ... def swapcase(self: Self) -> Self: ... def title(self: Self) -> Self: ... diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index d0bb8a98b..f3ffd3ec4 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -25,7 +25,7 @@ class CDLL: def __init__( self, name: str | None, - mode: int = 4, + mode: int = ..., handle: int | None = None, use_errno: bool = False, use_last_error: bool = False, diff --git a/stdlib/email/parser.pyi b/stdlib/email/parser.pyi index 6224624c8..ba5dace28 100644 --- a/stdlib/email/parser.pyi +++ b/stdlib/email/parser.pyi @@ -11,11 +11,15 @@ class Parser: def parse(self, fp: TextIO, headersonly: bool = False) -> Message: ... def parsestr(self, text: str, headersonly: bool = False) -> Message: ... -class HeaderParser(Parser): ... +class HeaderParser(Parser): + def parse(self, fp: TextIO, headersonly: bool = True) -> Message: ... + def parsestr(self, text: str, headersonly: bool = True) -> Message: ... class BytesParser: def __init__(self, _class: Callable[[], Message] = ..., *, policy: Policy = ...) -> None: ... def parse(self, fp: BinaryIO, headersonly: bool = False) -> Message: ... def parsebytes(self, text: bytes | bytearray, headersonly: bool = False) -> Message: ... -class BytesHeaderParser(BytesParser): ... +class BytesHeaderParser(BytesParser): + def parse(self, fp: BinaryIO, headersonly: bool = True) -> Message: ... + def parsebytes(self, text: bytes | bytearray, headersonly: bool = True) -> Message: ... diff --git a/stdlib/multiprocessing/heap.pyi b/stdlib/multiprocessing/heap.pyi index 08ad0a6b8..b5e2ced5e 100644 --- a/stdlib/multiprocessing/heap.pyi +++ b/stdlib/multiprocessing/heap.pyi @@ -27,7 +27,7 @@ if sys.platform != "win32": def rebuild_arena(size: int, dupfd: _SupportsDetach) -> Arena: ... class Heap: - def __init__(self, size: int = 16384) -> None: ... + def __init__(self, size: int = ...) -> None: ... def free(self, block: _Block) -> None: ... def malloc(self, size: int) -> _Block: ... diff --git a/stdlib/platform.pyi b/stdlib/platform.pyi index 3dc408116..c683ba596 100644 --- a/stdlib/platform.pyi +++ b/stdlib/platform.pyi @@ -37,9 +37,7 @@ def java_ver( release: str = "", vendor: str = "", vminfo: tuple[str, str, str] = ..., osinfo: tuple[str, str, str] = ... ) -> tuple[str, str, tuple[str, str, str], tuple[str, str, str]]: ... def system_alias(system: str, release: str, version: str) -> tuple[str, str, str]: ... -def architecture( - executable: str = "/Users/jelle/py/venvs/py311/bin/python", bits: str = "", linkage: str = "" -) -> tuple[str, str]: ... +def architecture(executable: str = ..., bits: str = "", linkage: str = "") -> tuple[str, str]: ... class uname_result(NamedTuple): system: str diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index 3028c3a90..904550a66 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -58,7 +58,7 @@ class Doc: def docproperty(self, object: object, name: str | None = None, *args: Any) -> str: ... @abstractmethod def docdata(self, object: object, name: str | None = None, *args: Any) -> str: ... - def getdocloc(self, object: object, basedir: str = "/Users/jelle/.pyenv/versions/3.11.1/lib/python3.11") -> str | None: ... + def getdocloc(self, object: object, basedir: str = ...) -> str | None: ... class HTMLRepr(Repr): def escape(self, text: str) -> str: ... diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index 2e7598421..41f3e7d3d 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -779,7 +779,12 @@ else: if sys.version_info >= (3, 8): def has_dualstack_ipv6() -> bool: ... def create_server( - address: _Address, *, family: int = 2, backlog: int | None = None, reuse_port: bool = False, dualstack_ipv6: bool = False + address: _Address, + *, + family: int = ..., + backlog: int | None = None, + reuse_port: bool = False, + dualstack_ipv6: bool = False, ) -> socket: ... # the 5th tuple item is an address diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index b2b57e6a9..a80980016 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -49,8 +49,8 @@ def wrap_socket( keyfile: StrOrBytesPath | None = None, certfile: StrOrBytesPath | None = None, server_side: bool = False, - cert_reqs: int = 0, - ssl_version: int = 2, + cert_reqs: int = ..., + ssl_version: int = ..., ca_certs: str | None = None, do_handshake_on_connect: bool = True, suppress_ragged_eofs: bool = True, @@ -68,7 +68,7 @@ if sys.version_info >= (3, 10): def _create_unverified_context( protocol: int | None = None, *, - cert_reqs: int = 0, + cert_reqs: int = ..., check_hostname: bool = False, purpose: Purpose = ..., certfile: StrOrBytesPath | None = None, @@ -83,13 +83,13 @@ else: protocol: int = ..., *, cert_reqs: int = ..., - check_hostname: bool = ..., + check_hostname: bool = False, purpose: Purpose = ..., - certfile: StrOrBytesPath | None = ..., - keyfile: StrOrBytesPath | None = ..., - cafile: StrOrBytesPath | None = ..., - capath: StrOrBytesPath | None = ..., - cadata: str | ReadableBuffer | None = ..., + certfile: StrOrBytesPath | None = None, + keyfile: StrOrBytesPath | None = None, + cafile: StrOrBytesPath | None = None, + capath: StrOrBytesPath | None = None, + cadata: str | ReadableBuffer | None = None, ) -> SSLContext: ... _create_default_https_context: Callable[..., SSLContext] @@ -107,11 +107,11 @@ def cert_time_to_seconds(cert_time: str) -> int: ... if sys.version_info >= (3, 10): def get_server_certificate( - addr: tuple[str, int], ssl_version: int = 16, ca_certs: str | None = None, timeout: float = ... + addr: tuple[str, int], ssl_version: int = ..., ca_certs: str | None = None, timeout: float = ... ) -> str: ... else: - def get_server_certificate(addr: tuple[str, int], ssl_version: int = ..., ca_certs: str | None = ...) -> str: ... + def get_server_certificate(addr: tuple[str, int], ssl_version: int = ..., ca_certs: str | None = None) -> str: ... def DER_cert_to_PEM_cert(der_cert_bytes: ReadableBuffer) -> str: ... def PEM_cert_to_DER_cert(pem_cert_string: str) -> bytes: ... diff --git a/stdlib/sysconfig.pyi b/stdlib/sysconfig.pyi index a1ce173cc..7e29cf132 100644 --- a/stdlib/sysconfig.pyi +++ b/stdlib/sysconfig.pyi @@ -28,8 +28,8 @@ if sys.version_info >= (3, 10): def get_preferred_scheme(key: Literal["prefix", "home", "user"]) -> str: ... def get_path_names() -> tuple[str, ...]: ... -def get_path(name: str, scheme: str = "venv", vars: dict[str, Any] | None = None, expand: bool = True) -> str: ... -def get_paths(scheme: str = "venv", vars: dict[str, Any] | None = None, expand: bool = True) -> dict[str, str]: ... +def get_path(name: str, scheme: str = ..., vars: dict[str, Any] | None = None, expand: bool = True) -> str: ... +def get_paths(scheme: str = ..., vars: dict[str, Any] | None = None, expand: bool = True) -> dict[str, str]: ... def get_python_version() -> str: ... def get_platform() -> str: ...