[stdlib] Add default values part 2 (#14769)

This commit is contained in:
Semyon Moroz
2026-01-11 19:08:32 +00:00
committed by GitHub
parent a4eeb5c05b
commit 3593e35df4
12 changed files with 142 additions and 117 deletions
+8 -6
View File
@@ -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: ...
+1 -1
View File
@@ -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]
+6 -6
View File
@@ -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: ...
+9 -2
View File
@@ -1,6 +1,6 @@
import pickle
import sys
from _pickle import _ReducedType
from _pickle import _BufferCallback, _ReducedType
from _typeshed import HasFileno, SupportsWrite, Unused
from abc import ABCMeta
from builtins import type as Type # alias to avoid name clash
@@ -19,7 +19,14 @@ 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,
fix_imports: bool = True,
buffer_callback: _BufferCallback = None,
/,
) -> None: ...
@classmethod
def register(cls, type: Type, reduce: Callable[[Any], _ReducedType]) -> None: ...
@classmethod
+50 -50
View File
@@ -1037,10 +1037,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(
@@ -1050,8 +1050,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(
@@ -1061,8 +1061,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(
@@ -1072,8 +1072,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(
@@ -1083,8 +1083,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(
@@ -1094,8 +1094,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(
@@ -1103,10 +1103,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: ...
@@ -1538,13 +1538,13 @@ else:
env: _ExecEnv | None, # None allowed starting in 3.13
/,
*,
file_actions: Sequence[tuple[Any, ...]] | None = ...,
setpgroup: int | None = ...,
resetids: bool = ...,
setsid: bool = ...,
setsigmask: Iterable[int] = ...,
setsigdef: Iterable[int] = ...,
scheduler: tuple[Any, sched_param] | None = ...,
file_actions: Sequence[tuple[Any, ...]] | None = (),
setpgroup: int = ...,
resetids: bool = False,
setsid: bool = False,
setsigmask: Iterable[int] = (),
setsigdef: Iterable[int] = (),
scheduler: tuple[Any, sched_param] = ...,
) -> int: ...
def posix_spawnp(
path: StrOrBytesPath,
@@ -1552,13 +1552,13 @@ else:
env: _ExecEnv | None, # None allowed starting in 3.13
/,
*,
file_actions: Sequence[tuple[Any, ...]] | None = ...,
setpgroup: int | None = ...,
resetids: bool = ...,
setsid: bool = ...,
setsigmask: Iterable[int] = ...,
setsigdef: Iterable[int] = ...,
scheduler: tuple[Any, sched_param] | None = ...,
file_actions: Sequence[tuple[Any, ...]] | None = (),
setpgroup: int = ...,
resetids: bool = False,
setsid: bool = False,
setsigmask: Iterable[int] = (),
setsigdef: Iterable[int] = (),
scheduler: tuple[Any, sched_param] = ...,
) -> int: ...
else:
def posix_spawn(
@@ -1567,13 +1567,13 @@ else:
env: _ExecEnv,
/,
*,
file_actions: Sequence[tuple[Any, ...]] | None = ...,
setpgroup: int | None = ...,
resetids: bool = ...,
setsid: bool = ...,
setsigmask: Iterable[int] = ...,
setsigdef: Iterable[int] = ...,
scheduler: tuple[Any, sched_param] | None = ...,
file_actions: Sequence[tuple[Any, ...]] | None = (),
setpgroup: int = ...,
resetids: bool = False,
setsid: bool = False,
setsigmask: Iterable[int] = (),
setsigdef: Iterable[int] = (),
scheduler: tuple[Any, sched_param] = ...,
) -> int: ...
def posix_spawnp(
path: StrOrBytesPath,
@@ -1581,13 +1581,13 @@ else:
env: _ExecEnv,
/,
*,
file_actions: Sequence[tuple[Any, ...]] | None = ...,
setpgroup: int | None = ...,
resetids: bool = ...,
setsid: bool = ...,
setsigmask: Iterable[int] = ...,
setsigdef: Iterable[int] = ...,
scheduler: tuple[Any, sched_param] | None = ...,
file_actions: Sequence[tuple[Any, ...]] | None = (),
setpgroup: int = ...,
resetids: bool = False,
setsid: bool = False,
setsigmask: Iterable[int] = (),
setsigdef: Iterable[int] = (),
scheduler: tuple[Any, sched_param] = ...,
) -> int: ...
POSIX_SPAWN_OPEN: Final = 0
@@ -1674,12 +1674,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
@@ -1703,8 +1703,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: ...
+1 -1
View File
@@ -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,
+4 -1
View File
@@ -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: ...
+36 -32
View File
@@ -83,36 +83,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
@@ -354,6 +324,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
@@ -446,7 +450,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,
@@ -460,7 +464,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,
+1 -1
View File
@@ -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: ...
+12 -3
View File
@@ -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,
+7 -7
View File
@@ -363,8 +363,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: ...
@@ -381,11 +381,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):
+7 -7
View File
@@ -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: ...