diff --git a/stdlib/faulthandler.pyi b/stdlib/faulthandler.pyi index 33d08995eb75..17d4eef69af7 100644 --- a/stdlib/faulthandler.pyi +++ b/stdlib/faulthandler.pyi @@ -3,21 +3,23 @@ from _typeshed import FileDescriptorLike def cancel_dump_traceback_later() -> None: ... def disable() -> None: ... -def dump_traceback(file: FileDescriptorLike = ..., all_threads: bool = ...) -> None: ... +def dump_traceback(file: FileDescriptorLike = sys.stderr, all_threads: bool = True) -> None: ... if sys.version_info >= (3, 14): - def dump_c_stack(file: FileDescriptorLike = ...) -> None: ... + def dump_c_stack(file: FileDescriptorLike = sys.stderr) -> None: ... -def dump_traceback_later(timeout: float, repeat: bool = ..., file: FileDescriptorLike = ..., exit: bool = ...) -> None: ... +def dump_traceback_later( + timeout: float, repeat: bool = False, file: FileDescriptorLike = sys.stderr, exit: bool = False +) -> None: ... if sys.version_info >= (3, 14): - def enable(file: FileDescriptorLike = ..., all_threads: bool = ..., c_stack: bool = True) -> None: ... + def enable(file: FileDescriptorLike = sys.stderr, all_threads: bool = True, c_stack: bool = True) -> None: ... else: - def enable(file: FileDescriptorLike = ..., all_threads: bool = ...) -> None: ... + def enable(file: FileDescriptorLike = sys.stderr, all_threads: bool = True) -> None: ... def is_enabled() -> bool: ... if sys.platform != "win32": - def register(signum: int, file: FileDescriptorLike = ..., all_threads: bool = ..., chain: bool = ...) -> None: ... + def register(signum: int, file: FileDescriptorLike = sys.stderr, all_threads: bool = True, chain: bool = False) -> None: ... def unregister(signum: int, /) -> None: ... diff --git a/stdlib/hashlib.pyi b/stdlib/hashlib.pyi index 924136301b21..1763c2318273 100644 --- a/stdlib/hashlib.pyi +++ b/stdlib/hashlib.pyi @@ -66,7 +66,7 @@ else: "pbkdf2_hmac", ) -def new(name: str, data: ReadableBuffer = b"", *, usedforsecurity: bool = ...) -> HASH: ... +def new(name: str, data: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ... algorithms_guaranteed: AbstractSet[str] algorithms_available: AbstractSet[str] diff --git a/stdlib/itertools.pyi b/stdlib/itertools.pyi index fe4ccbdf8ae9..bbed0c0bc155 100644 --- a/stdlib/itertools.pyi +++ b/stdlib/itertools.pyi @@ -32,7 +32,7 @@ class count(Generic[_N]): @overload def __new__(cls) -> count[int]: ... @overload - def __new__(cls, start: _N, step: _Step = ...) -> count[_N]: ... + def __new__(cls, start: _N, step: _Step = 1) -> count[_N]: ... @overload def __new__(cls, *, step: _N) -> count[_N]: ... def __next__(self) -> _N: ... @@ -57,9 +57,9 @@ class repeat(Generic[_T]): @disjoint_base class accumulate(Generic[_T]): @overload - def __new__(cls, iterable: Iterable[_T], func: None = None, *, initial: _T | None = ...) -> Self: ... + def __new__(cls, iterable: Iterable[_T], func: None = None, *, initial: _T | None = None) -> Self: ... @overload - def __new__(cls, iterable: Iterable[_S], func: Callable[[_T, _S], _T], *, initial: _T | None = ...) -> Self: ... + def __new__(cls, iterable: Iterable[_S], func: Callable[[_T, _S], _T], *, initial: _T | None = None) -> Self: ... def __iter__(self) -> Self: ... def __next__(self) -> _T: ... @@ -105,7 +105,7 @@ class islice(Generic[_T]): @overload def __new__(cls, iterable: Iterable[_T], stop: int | None, /) -> Self: ... @overload - def __new__(cls, iterable: Iterable[_T], start: int | None, stop: int | None, step: int | None = ..., /) -> Self: ... + def __new__(cls, iterable: Iterable[_T], start: int | None, stop: int | None, step: int | None = 1, /) -> Self: ... def __iter__(self) -> Self: ... def __next__(self) -> _T: ... @@ -126,7 +126,7 @@ def tee(iterable: Iterable[_T], n: int = 2, /) -> tuple[Iterator[_T], ...]: ... class zip_longest(Generic[_T_co]): # one iterable (fillvalue doesn't matter) @overload - def __new__(cls, iter1: Iterable[_T1], /, *, fillvalue: object = ...) -> zip_longest[tuple[_T1]]: ... + def __new__(cls, iter1: Iterable[_T1], /, *, fillvalue: object = None) -> zip_longest[tuple[_T1]]: ... # two iterables @overload # In the overloads without fillvalue, all of the tuple members could theoretically be None, @@ -298,7 +298,7 @@ class permutations(Generic[_T_co]): @overload def __new__(cls, iterable: Iterable[_T], r: Literal[5]) -> permutations[tuple[_T, _T, _T, _T, _T]]: ... @overload - def __new__(cls, iterable: Iterable[_T], r: int | None = ...) -> permutations[tuple[_T, ...]]: ... + def __new__(cls, iterable: Iterable[_T], r: int | None = None) -> permutations[tuple[_T, ...]]: ... def __iter__(self) -> Self: ... def __next__(self) -> _T_co: ... diff --git a/stdlib/multiprocessing/reduction.pyi b/stdlib/multiprocessing/reduction.pyi index 490ae195c20e..ead14d570d17 100644 --- a/stdlib/multiprocessing/reduction.pyi +++ b/stdlib/multiprocessing/reduction.pyi @@ -19,7 +19,7 @@ HAVE_SEND_HANDLE: Final[bool] class ForkingPickler(pickle.Pickler): dispatch_table: _DispatchTableType - def __init__(self, file: SupportsWrite[bytes], protocol: int | None = ...) -> None: ... + def __init__(self, file: SupportsWrite[bytes], protocol: int | None = None) -> None: ... @classmethod def register(cls, type: Type, reduce: Callable[[Any], _ReducedType]) -> None: ... @classmethod diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 71c79dfac399..3ca5e35099e1 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -1020,10 +1020,10 @@ def fdopen( mode: OpenTextMode = "r", buffering: int = -1, encoding: str | None = None, - errors: str | None = ..., - newline: str | None = ..., - closefd: bool = ..., - opener: _Opener | None = ..., + errors: str | None = None, + newline: str | None = None, + closefd: bool = True, + opener: _Opener | None = None, ) -> TextIOWrapper: ... @overload def fdopen( @@ -1033,8 +1033,8 @@ def fdopen( encoding: None = None, errors: None = None, newline: None = None, - closefd: bool = ..., - opener: _Opener | None = ..., + closefd: bool = True, + opener: _Opener | None = None, ) -> FileIO: ... @overload def fdopen( @@ -1044,8 +1044,8 @@ def fdopen( encoding: None = None, errors: None = None, newline: None = None, - closefd: bool = ..., - opener: _Opener | None = ..., + closefd: bool = True, + opener: _Opener | None = None, ) -> BufferedRandom: ... @overload def fdopen( @@ -1055,8 +1055,8 @@ def fdopen( encoding: None = None, errors: None = None, newline: None = None, - closefd: bool = ..., - opener: _Opener | None = ..., + closefd: bool = True, + opener: _Opener | None = None, ) -> BufferedWriter: ... @overload def fdopen( @@ -1066,8 +1066,8 @@ def fdopen( encoding: None = None, errors: None = None, newline: None = None, - closefd: bool = ..., - opener: _Opener | None = ..., + closefd: bool = True, + opener: _Opener | None = None, ) -> BufferedReader: ... @overload def fdopen( @@ -1077,8 +1077,8 @@ def fdopen( encoding: None = None, errors: None = None, newline: None = None, - closefd: bool = ..., - opener: _Opener | None = ..., + closefd: bool = True, + opener: _Opener | None = None, ) -> BinaryIO: ... @overload def fdopen( @@ -1086,10 +1086,10 @@ def fdopen( mode: str, buffering: int = -1, encoding: str | None = None, - errors: str | None = ..., - newline: str | None = ..., - closefd: bool = ..., - opener: _Opener | None = ..., + errors: str | None = None, + newline: str | None = None, + closefd: bool = True, + opener: _Opener | None = None, ) -> IO[Any]: ... def close(fd: int) -> None: ... def closerange(fd_low: int, fd_high: int, /) -> None: ... @@ -1478,12 +1478,12 @@ else: env: _ExecEnv, /, *, - file_actions: Sequence[tuple[Any, ...]] | None = ..., + file_actions: Sequence[tuple[Any, ...]] | None = (), setpgroup: int | None = ..., - resetids: bool = ..., - setsid: bool = ..., - setsigmask: Iterable[int] = ..., - setsigdef: Iterable[int] = ..., + resetids: bool = False, + setsid: bool = False, + setsigmask: Iterable[int] = (), + setsigdef: Iterable[int] = (), scheduler: tuple[Any, sched_param] | None = ..., ) -> int: ... def posix_spawnp( @@ -1492,12 +1492,12 @@ else: env: _ExecEnv, /, *, - file_actions: Sequence[tuple[Any, ...]] | None = ..., + file_actions: Sequence[tuple[Any, ...]] | None = (), setpgroup: int | None = ..., - resetids: bool = ..., - setsid: bool = ..., - setsigmask: Iterable[int] = ..., - setsigdef: Iterable[int] = ..., + resetids: bool = False, + setsid: bool = False, + setsigmask: Iterable[int] = (), + setsigdef: Iterable[int] = (), scheduler: tuple[Any, sched_param] | None = ..., ) -> int: ... POSIX_SPAWN_OPEN: Final = 0 @@ -1584,12 +1584,12 @@ if sys.platform == "linux": MFD_HUGE_2GB: Final[int] MFD_HUGE_16GB: Final[int] def memfd_create(name: str, flags: int = ...) -> int: ... - def copy_file_range(src: int, dst: int, count: int, offset_src: int | None = ..., offset_dst: int | None = ...) -> int: ... + def copy_file_range(src: int, dst: int, count: int, offset_src: int | None = None, offset_dst: int | None = None) -> int: ... def waitstatus_to_exitcode(status: int) -> int: ... if sys.platform == "linux": - def pidfd_open(pid: int, flags: int = ...) -> int: ... + def pidfd_open(pid: int, flags: int = 0) -> int: ... if sys.version_info >= (3, 12) and sys.platform == "linux": PIDFD_NONBLOCK: Final = 2048 @@ -1613,8 +1613,8 @@ if sys.version_info >= (3, 10) and sys.platform == "linux": src: FileDescriptor, dst: FileDescriptor, count: int, - offset_src: int | None = ..., - offset_dst: int | None = ..., + offset_src: int | None = None, + offset_dst: int | None = None, flags: int = 0, ) -> int: ... diff --git a/stdlib/pstats.pyi b/stdlib/pstats.pyi index c4dee1f6b8f6..c1da2aea0fc5 100644 --- a/stdlib/pstats.pyi +++ b/stdlib/pstats.pyi @@ -61,7 +61,7 @@ class Stats: sort_arg_dict_default: _SortArgDict def __init__( self, - arg: None | str | Profile | _cProfile = ..., + arg: None | str | Profile | _cProfile = None, /, *args: None | str | Profile | _cProfile | Self, stream: IO[Any] | None = None, diff --git a/stdlib/sched.pyi b/stdlib/sched.pyi index 52f87ab68ff5..436d9984ee4d 100644 --- a/stdlib/sched.pyi +++ b/stdlib/sched.pyi @@ -1,4 +1,5 @@ import sys +import time from collections.abc import Callable from typing import Any, ClassVar, NamedTuple, type_check_only from typing_extensions import TypeAlias @@ -32,7 +33,9 @@ class scheduler: timefunc: Callable[[], float] delayfunc: Callable[[float], object] - def __init__(self, timefunc: Callable[[], float] = ..., delayfunc: Callable[[float], object] = ...) -> None: ... + def __init__( + self, timefunc: Callable[[], float] = time.monotonic, delayfunc: Callable[[float], object] = time.sleep + ) -> None: ... def enterabs( self, time: float, priority: Any, action: _ActionCallback, argument: tuple[Any, ...] = (), kwargs: dict[str, Any] = ... ) -> Event: ... diff --git a/stdlib/select.pyi b/stdlib/select.pyi index 587bc75376ef..765004fda554 100644 --- a/stdlib/select.pyi +++ b/stdlib/select.pyi @@ -48,13 +48,7 @@ if sys.platform != "linux" and sys.platform != "win32": ident: int udata: Any def __init__( - self, - ident: FileDescriptorLike, - filter: int = ..., - flags: int = ..., - fflags: int = ..., - data: Any = ..., - udata: Any = ..., + self, ident: FileDescriptorLike, filter: int = ..., flags: int = ..., fflags: int = 0, data: Any = 0, udata: Any = 0 ) -> None: ... __hash__: ClassVar[None] # type: ignore[assignment] @@ -114,12 +108,12 @@ if sys.platform != "linux" and sys.platform != "win32": if sys.platform == "linux": @final class epoll: - def __new__(self, sizehint: int = ..., flags: int = ...) -> Self: ... + def __new__(self, sizehint: int = -1, flags: int = 0) -> Self: ... def __enter__(self) -> Self: ... def __exit__( self, exc_type: type[BaseException] | None = None, - exc_value: BaseException | None = ..., + exc_value: BaseException | None = None, exc_tb: TracebackType | None = None, /, ) -> None: ... @@ -160,4 +154,4 @@ if sys.platform != "linux" and sys.platform != "darwin" and sys.platform != "win def register(self, fd: FileDescriptorLike, eventmask: int = ...) -> None: ... def modify(self, fd: FileDescriptorLike, eventmask: int = ...) -> None: ... def unregister(self, fd: FileDescriptorLike) -> None: ... - def poll(self, timeout: float | None = ...) -> list[tuple[int, int]]: ... + def poll(self, timeout: float | None = None) -> list[tuple[int, int]]: ... diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index faa98cb39920..3c07fd466d30 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -80,36 +80,6 @@ class SSLCertVerificationError(SSLError, ValueError): CertificateError = SSLCertVerificationError -if sys.version_info < (3, 12): - @deprecated("Deprecated since Python 3.7; removed in Python 3.12. Use `SSLContext.wrap_socket()` instead.") - def wrap_socket( - sock: socket.socket, - keyfile: StrOrBytesPath | None = None, - certfile: StrOrBytesPath | None = None, - server_side: bool = False, - cert_reqs: int = ..., - ssl_version: int = ..., - ca_certs: str | None = None, - do_handshake_on_connect: bool = True, - suppress_ragged_eofs: bool = True, - ciphers: str | None = None, - ) -> SSLSocket: ... - @deprecated("Deprecated since Python 3.7; removed in Python 3.12.") - def match_hostname(cert: _PeerCertRetDictType, hostname: str) -> None: ... - -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 = ..., ca_certs: str | None = None, timeout: float = ... - ) -> str: ... - -else: - 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: ... - class DefaultVerifyPaths(NamedTuple): cafile: str capath: str @@ -351,6 +321,40 @@ class SSLSocket(socket.socket): def get_verified_chain(self) -> list[bytes]: ... def get_unverified_chain(self) -> list[bytes]: ... +if sys.version_info < (3, 12): + @deprecated("Deprecated since Python 3.7; removed in Python 3.12. Use `SSLContext.wrap_socket()` instead.") + def wrap_socket( + sock: socket.socket, + keyfile: StrOrBytesPath | None = None, + certfile: StrOrBytesPath | None = None, + server_side: bool = False, + cert_reqs: int = VerifyMode.CERT_NONE, + ssl_version: int = _SSLMethod.PROTOCOL_TLS, + ca_certs: str | None = None, + do_handshake_on_connect: bool = True, + suppress_ragged_eofs: bool = True, + ciphers: str | None = None, + ) -> SSLSocket: ... + @deprecated("Deprecated since Python 3.7; removed in Python 3.12.") + def match_hostname(cert: _PeerCertRetDictType, hostname: str) -> None: ... + +def cert_time_to_seconds(cert_time: str) -> int: ... +def DER_cert_to_PEM_cert(der_cert_bytes: ReadableBuffer) -> str: ... +def PEM_cert_to_DER_cert(pem_cert_string: str) -> bytes: ... + +if sys.version_info >= (3, 10): + def get_server_certificate( + addr: tuple[str, int], + ssl_version: int = _SSLMethod.PROTOCOL_TLS_CLIENT, + ca_certs: str | None = None, + timeout: float = ..., + ) -> str: ... + +else: + def get_server_certificate( + addr: tuple[str, int], ssl_version: int = _SSLMethod.PROTOCOL_TLS_CLIENT, ca_certs: str | None = None + ) -> str: ... + class TLSVersion(enum.IntEnum): MINIMUM_SUPPORTED = -2 MAXIMUM_SUPPORTED = -1 @@ -443,7 +447,7 @@ if sys.version_info >= (3, 10): def _create_unverified_context( protocol: int | None = None, *, - cert_reqs: int = ..., + cert_reqs: int = VerifyMode.CERT_NONE, check_hostname: bool = False, purpose: Purpose = Purpose.SERVER_AUTH, certfile: StrOrBytesPath | None = None, @@ -457,7 +461,7 @@ else: def _create_unverified_context( protocol: int = ..., *, - cert_reqs: int = ..., + cert_reqs: int = VerifyMode.CERT_NONE, check_hostname: bool = False, purpose: Purpose = Purpose.SERVER_AUTH, certfile: StrOrBytesPath | None = None, diff --git a/stdlib/syslog.pyi b/stdlib/syslog.pyi index 1e0d0d383902..b639c28c7f2d 100644 --- a/stdlib/syslog.pyi +++ b/stdlib/syslog.pyi @@ -49,7 +49,7 @@ if sys.platform != "win32": def LOG_MASK(pri: int, /) -> int: ... def LOG_UPTO(pri: int, /) -> int: ... def closelog() -> None: ... - def openlog(ident: str = ..., logoption: int = ..., facility: int = ...) -> None: ... + def openlog(ident: str = ..., logoption: int = 0, facility: int = ...) -> None: ... def setlogmask(maskpri: int, /) -> int: ... @overload def syslog(priority: int, message: str) -> None: ... diff --git a/stdlib/timeit.pyi b/stdlib/timeit.pyi index a5da943c8484..61935815f68b 100644 --- a/stdlib/timeit.pyi +++ b/stdlib/timeit.pyi @@ -1,3 +1,4 @@ +import time from collections.abc import Callable, Sequence from typing import IO, Any from typing_extensions import TypeAlias @@ -11,7 +12,11 @@ default_timer: _Timer class Timer: def __init__( - self, stmt: _Stmt = "pass", setup: _Stmt = "pass", timer: _Timer = ..., globals: dict[str, Any] | None = None + self, + stmt: _Stmt = "pass", + setup: _Stmt = "pass", + timer: _Timer = time.perf_counter, + globals: dict[str, Any] | None = None, ) -> None: ... def print_exc(self, file: IO[str] | None = None) -> None: ... def timeit(self, number: int = 1000000) -> float: ... @@ -19,12 +24,16 @@ class Timer: def autorange(self, callback: Callable[[int, float], object] | None = None) -> tuple[int, float]: ... def timeit( - stmt: _Stmt = "pass", setup: _Stmt = "pass", timer: _Timer = ..., number: int = 1000000, globals: dict[str, Any] | None = None + stmt: _Stmt = "pass", + setup: _Stmt = "pass", + timer: _Timer = time.perf_counter, + number: int = 1000000, + globals: dict[str, Any] | None = None, ) -> float: ... def repeat( stmt: _Stmt = "pass", setup: _Stmt = "pass", - timer: _Timer = ..., + timer: _Timer = time.perf_counter, repeat: int = 5, number: int = 1000000, globals: dict[str, Any] | None = None, diff --git a/stdlib/zipfile/__init__.pyi b/stdlib/zipfile/__init__.pyi index e573d04dba05..ba845988caa8 100644 --- a/stdlib/zipfile/__init__.pyi +++ b/stdlib/zipfile/__init__.pyi @@ -361,8 +361,8 @@ else: encoding: str | None = None, errors: str | None = None, newline: str | None = None, - line_buffering: bool = ..., - write_through: bool = ..., + line_buffering: bool = False, + write_through: bool = False, *, pwd: bytes | None = None, ) -> TextIOWrapper: ... @@ -379,11 +379,11 @@ else: def exists(self) -> bool: ... def read_text( self, - encoding: str | None = ..., - errors: str | None = ..., - newline: str | None = ..., - line_buffering: bool = ..., - write_through: bool = ..., + encoding: str | None = None, + errors: str | None = None, + newline: str | None = None, + line_buffering: bool = False, + write_through: bool = False, ) -> str: ... def read_bytes(self) -> bytes: ... if sys.version_info >= (3, 10): diff --git a/stdlib/zipfile/_path/__init__.pyi b/stdlib/zipfile/_path/__init__.pyi index 4c7b39ec4c6c..c936c4494c7c 100644 --- a/stdlib/zipfile/_path/__init__.pyi +++ b/stdlib/zipfile/_path/__init__.pyi @@ -52,8 +52,8 @@ if sys.version_info >= (3, 12): encoding: str | None = None, errors: str | None = None, newline: str | None = None, - line_buffering: bool = ..., - write_through: bool = ..., + line_buffering: bool = False, + write_through: bool = False, *, pwd: bytes | None = None, ) -> TextIOWrapper: ... @@ -65,11 +65,11 @@ if sys.version_info >= (3, 12): def exists(self) -> bool: ... def read_text( self, - encoding: str | None = ..., - errors: str | None = ..., - newline: str | None = ..., - line_buffering: bool = ..., - write_through: bool = ..., + encoding: str | None = None, + errors: str | None = None, + newline: str | None = None, + line_buffering: bool = False, + write_through: bool = False, ) -> str: ... def read_bytes(self) -> bytes: ... def joinpath(self, *other: StrPath) -> Path: ...