Skip to content

Commit 3593e35

Browse files
authored
[stdlib] Add default values part 2 (#14769)
1 parent a4eeb5c commit 3593e35

File tree

12 files changed

+142
-117
lines changed

12 files changed

+142
-117
lines changed

stdlib/faulthandler.pyi

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@ from _typeshed import FileDescriptorLike
33

44
def cancel_dump_traceback_later() -> None: ...
55
def disable() -> None: ...
6-
def dump_traceback(file: FileDescriptorLike = ..., all_threads: bool = ...) -> None: ...
6+
def dump_traceback(file: FileDescriptorLike = sys.stderr, all_threads: bool = True) -> None: ...
77

88
if sys.version_info >= (3, 14):
9-
def dump_c_stack(file: FileDescriptorLike = ...) -> None: ...
9+
def dump_c_stack(file: FileDescriptorLike = sys.stderr) -> None: ...
1010

11-
def dump_traceback_later(timeout: float, repeat: bool = ..., file: FileDescriptorLike = ..., exit: bool = ...) -> None: ...
11+
def dump_traceback_later(
12+
timeout: float, repeat: bool = False, file: FileDescriptorLike = sys.stderr, exit: bool = False
13+
) -> None: ...
1214

1315
if sys.version_info >= (3, 14):
14-
def enable(file: FileDescriptorLike = ..., all_threads: bool = ..., c_stack: bool = True) -> None: ...
16+
def enable(file: FileDescriptorLike = sys.stderr, all_threads: bool = True, c_stack: bool = True) -> None: ...
1517

1618
else:
17-
def enable(file: FileDescriptorLike = ..., all_threads: bool = ...) -> None: ...
19+
def enable(file: FileDescriptorLike = sys.stderr, all_threads: bool = True) -> None: ...
1820

1921
def is_enabled() -> bool: ...
2022

2123
if sys.platform != "win32":
22-
def register(signum: int, file: FileDescriptorLike = ..., all_threads: bool = ..., chain: bool = ...) -> None: ...
24+
def register(signum: int, file: FileDescriptorLike = sys.stderr, all_threads: bool = True, chain: bool = False) -> None: ...
2325
def unregister(signum: int, /) -> None: ...

stdlib/hashlib.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ else:
6666
"pbkdf2_hmac",
6767
)
6868

69-
def new(name: str, data: ReadableBuffer = b"", *, usedforsecurity: bool = ...) -> HASH: ...
69+
def new(name: str, data: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
7070

7171
algorithms_guaranteed: AbstractSet[str]
7272
algorithms_available: AbstractSet[str]

stdlib/itertools.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class count(Generic[_N]):
3232
@overload
3333
def __new__(cls) -> count[int]: ...
3434
@overload
35-
def __new__(cls, start: _N, step: _Step = ...) -> count[_N]: ...
35+
def __new__(cls, start: _N, step: _Step = 1) -> count[_N]: ...
3636
@overload
3737
def __new__(cls, *, step: _N) -> count[_N]: ...
3838
def __next__(self) -> _N: ...
@@ -57,9 +57,9 @@ class repeat(Generic[_T]):
5757
@disjoint_base
5858
class accumulate(Generic[_T]):
5959
@overload
60-
def __new__(cls, iterable: Iterable[_T], func: None = None, *, initial: _T | None = ...) -> Self: ...
60+
def __new__(cls, iterable: Iterable[_T], func: None = None, *, initial: _T | None = None) -> Self: ...
6161
@overload
62-
def __new__(cls, iterable: Iterable[_S], func: Callable[[_T, _S], _T], *, initial: _T | None = ...) -> Self: ...
62+
def __new__(cls, iterable: Iterable[_S], func: Callable[[_T, _S], _T], *, initial: _T | None = None) -> Self: ...
6363
def __iter__(self) -> Self: ...
6464
def __next__(self) -> _T: ...
6565

@@ -105,7 +105,7 @@ class islice(Generic[_T]):
105105
@overload
106106
def __new__(cls, iterable: Iterable[_T], stop: int | None, /) -> Self: ...
107107
@overload
108-
def __new__(cls, iterable: Iterable[_T], start: int | None, stop: int | None, step: int | None = ..., /) -> Self: ...
108+
def __new__(cls, iterable: Iterable[_T], start: int | None, stop: int | None, step: int | None = 1, /) -> Self: ...
109109
def __iter__(self) -> Self: ...
110110
def __next__(self) -> _T: ...
111111

@@ -126,7 +126,7 @@ def tee(iterable: Iterable[_T], n: int = 2, /) -> tuple[Iterator[_T], ...]: ...
126126
class zip_longest(Generic[_T_co]):
127127
# one iterable (fillvalue doesn't matter)
128128
@overload
129-
def __new__(cls, iter1: Iterable[_T1], /, *, fillvalue: object = ...) -> zip_longest[tuple[_T1]]: ...
129+
def __new__(cls, iter1: Iterable[_T1], /, *, fillvalue: object = None) -> zip_longest[tuple[_T1]]: ...
130130
# two iterables
131131
@overload
132132
# In the overloads without fillvalue, all of the tuple members could theoretically be None,
@@ -298,7 +298,7 @@ class permutations(Generic[_T_co]):
298298
@overload
299299
def __new__(cls, iterable: Iterable[_T], r: Literal[5]) -> permutations[tuple[_T, _T, _T, _T, _T]]: ...
300300
@overload
301-
def __new__(cls, iterable: Iterable[_T], r: int | None = ...) -> permutations[tuple[_T, ...]]: ...
301+
def __new__(cls, iterable: Iterable[_T], r: int | None = None) -> permutations[tuple[_T, ...]]: ...
302302
def __iter__(self) -> Self: ...
303303
def __next__(self) -> _T_co: ...
304304

stdlib/multiprocessing/reduction.pyi

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pickle
22
import sys
3-
from _pickle import _ReducedType
3+
from _pickle import _BufferCallback, _ReducedType
44
from _typeshed import HasFileno, SupportsWrite, Unused
55
from abc import ABCMeta
66
from builtins import type as Type # alias to avoid name clash
@@ -19,7 +19,14 @@ HAVE_SEND_HANDLE: Final[bool]
1919

2020
class ForkingPickler(pickle.Pickler):
2121
dispatch_table: _DispatchTableType
22-
def __init__(self, file: SupportsWrite[bytes], protocol: int | None = ...) -> None: ...
22+
def __init__(
23+
self,
24+
file: SupportsWrite[bytes],
25+
protocol: int | None = None,
26+
fix_imports: bool = True,
27+
buffer_callback: _BufferCallback = None,
28+
/,
29+
) -> None: ...
2330
@classmethod
2431
def register(cls, type: Type, reduce: Callable[[Any], _ReducedType]) -> None: ...
2532
@classmethod

stdlib/os/__init__.pyi

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,10 +1037,10 @@ def fdopen(
10371037
mode: OpenTextMode = "r",
10381038
buffering: int = -1,
10391039
encoding: str | None = None,
1040-
errors: str | None = ...,
1041-
newline: str | None = ...,
1042-
closefd: bool = ...,
1043-
opener: _Opener | None = ...,
1040+
errors: str | None = None,
1041+
newline: str | None = None,
1042+
closefd: bool = True,
1043+
opener: _Opener | None = None,
10441044
) -> TextIOWrapper: ...
10451045
@overload
10461046
def fdopen(
@@ -1050,8 +1050,8 @@ def fdopen(
10501050
encoding: None = None,
10511051
errors: None = None,
10521052
newline: None = None,
1053-
closefd: bool = ...,
1054-
opener: _Opener | None = ...,
1053+
closefd: bool = True,
1054+
opener: _Opener | None = None,
10551055
) -> FileIO: ...
10561056
@overload
10571057
def fdopen(
@@ -1061,8 +1061,8 @@ def fdopen(
10611061
encoding: None = None,
10621062
errors: None = None,
10631063
newline: None = None,
1064-
closefd: bool = ...,
1065-
opener: _Opener | None = ...,
1064+
closefd: bool = True,
1065+
opener: _Opener | None = None,
10661066
) -> BufferedRandom: ...
10671067
@overload
10681068
def fdopen(
@@ -1072,8 +1072,8 @@ def fdopen(
10721072
encoding: None = None,
10731073
errors: None = None,
10741074
newline: None = None,
1075-
closefd: bool = ...,
1076-
opener: _Opener | None = ...,
1075+
closefd: bool = True,
1076+
opener: _Opener | None = None,
10771077
) -> BufferedWriter: ...
10781078
@overload
10791079
def fdopen(
@@ -1083,8 +1083,8 @@ def fdopen(
10831083
encoding: None = None,
10841084
errors: None = None,
10851085
newline: None = None,
1086-
closefd: bool = ...,
1087-
opener: _Opener | None = ...,
1086+
closefd: bool = True,
1087+
opener: _Opener | None = None,
10881088
) -> BufferedReader: ...
10891089
@overload
10901090
def fdopen(
@@ -1094,19 +1094,19 @@ def fdopen(
10941094
encoding: None = None,
10951095
errors: None = None,
10961096
newline: None = None,
1097-
closefd: bool = ...,
1098-
opener: _Opener | None = ...,
1097+
closefd: bool = True,
1098+
opener: _Opener | None = None,
10991099
) -> BinaryIO: ...
11001100
@overload
11011101
def fdopen(
11021102
fd: int,
11031103
mode: str,
11041104
buffering: int = -1,
11051105
encoding: str | None = None,
1106-
errors: str | None = ...,
1107-
newline: str | None = ...,
1108-
closefd: bool = ...,
1109-
opener: _Opener | None = ...,
1106+
errors: str | None = None,
1107+
newline: str | None = None,
1108+
closefd: bool = True,
1109+
opener: _Opener | None = None,
11101110
) -> IO[Any]: ...
11111111
def close(fd: int) -> None: ...
11121112
def closerange(fd_low: int, fd_high: int, /) -> None: ...
@@ -1538,27 +1538,27 @@ else:
15381538
env: _ExecEnv | None, # None allowed starting in 3.13
15391539
/,
15401540
*,
1541-
file_actions: Sequence[tuple[Any, ...]] | None = ...,
1542-
setpgroup: int | None = ...,
1543-
resetids: bool = ...,
1544-
setsid: bool = ...,
1545-
setsigmask: Iterable[int] = ...,
1546-
setsigdef: Iterable[int] = ...,
1547-
scheduler: tuple[Any, sched_param] | None = ...,
1541+
file_actions: Sequence[tuple[Any, ...]] | None = (),
1542+
setpgroup: int = ...,
1543+
resetids: bool = False,
1544+
setsid: bool = False,
1545+
setsigmask: Iterable[int] = (),
1546+
setsigdef: Iterable[int] = (),
1547+
scheduler: tuple[Any, sched_param] = ...,
15481548
) -> int: ...
15491549
def posix_spawnp(
15501550
path: StrOrBytesPath,
15511551
argv: _ExecVArgs,
15521552
env: _ExecEnv | None, # None allowed starting in 3.13
15531553
/,
15541554
*,
1555-
file_actions: Sequence[tuple[Any, ...]] | None = ...,
1556-
setpgroup: int | None = ...,
1557-
resetids: bool = ...,
1558-
setsid: bool = ...,
1559-
setsigmask: Iterable[int] = ...,
1560-
setsigdef: Iterable[int] = ...,
1561-
scheduler: tuple[Any, sched_param] | None = ...,
1555+
file_actions: Sequence[tuple[Any, ...]] | None = (),
1556+
setpgroup: int = ...,
1557+
resetids: bool = False,
1558+
setsid: bool = False,
1559+
setsigmask: Iterable[int] = (),
1560+
setsigdef: Iterable[int] = (),
1561+
scheduler: tuple[Any, sched_param] = ...,
15621562
) -> int: ...
15631563
else:
15641564
def posix_spawn(
@@ -1567,27 +1567,27 @@ else:
15671567
env: _ExecEnv,
15681568
/,
15691569
*,
1570-
file_actions: Sequence[tuple[Any, ...]] | None = ...,
1571-
setpgroup: int | None = ...,
1572-
resetids: bool = ...,
1573-
setsid: bool = ...,
1574-
setsigmask: Iterable[int] = ...,
1575-
setsigdef: Iterable[int] = ...,
1576-
scheduler: tuple[Any, sched_param] | None = ...,
1570+
file_actions: Sequence[tuple[Any, ...]] | None = (),
1571+
setpgroup: int = ...,
1572+
resetids: bool = False,
1573+
setsid: bool = False,
1574+
setsigmask: Iterable[int] = (),
1575+
setsigdef: Iterable[int] = (),
1576+
scheduler: tuple[Any, sched_param] = ...,
15771577
) -> int: ...
15781578
def posix_spawnp(
15791579
path: StrOrBytesPath,
15801580
argv: _ExecVArgs,
15811581
env: _ExecEnv,
15821582
/,
15831583
*,
1584-
file_actions: Sequence[tuple[Any, ...]] | None = ...,
1585-
setpgroup: int | None = ...,
1586-
resetids: bool = ...,
1587-
setsid: bool = ...,
1588-
setsigmask: Iterable[int] = ...,
1589-
setsigdef: Iterable[int] = ...,
1590-
scheduler: tuple[Any, sched_param] | None = ...,
1584+
file_actions: Sequence[tuple[Any, ...]] | None = (),
1585+
setpgroup: int = ...,
1586+
resetids: bool = False,
1587+
setsid: bool = False,
1588+
setsigmask: Iterable[int] = (),
1589+
setsigdef: Iterable[int] = (),
1590+
scheduler: tuple[Any, sched_param] = ...,
15911591
) -> int: ...
15921592

15931593
POSIX_SPAWN_OPEN: Final = 0
@@ -1674,12 +1674,12 @@ if sys.platform == "linux":
16741674
MFD_HUGE_2GB: Final[int]
16751675
MFD_HUGE_16GB: Final[int]
16761676
def memfd_create(name: str, flags: int = ...) -> int: ...
1677-
def copy_file_range(src: int, dst: int, count: int, offset_src: int | None = ..., offset_dst: int | None = ...) -> int: ...
1677+
def copy_file_range(src: int, dst: int, count: int, offset_src: int | None = None, offset_dst: int | None = None) -> int: ...
16781678

16791679
def waitstatus_to_exitcode(status: int) -> int: ...
16801680

16811681
if sys.platform == "linux":
1682-
def pidfd_open(pid: int, flags: int = ...) -> int: ...
1682+
def pidfd_open(pid: int, flags: int = 0) -> int: ...
16831683

16841684
if sys.version_info >= (3, 12) and sys.platform == "linux":
16851685
PIDFD_NONBLOCK: Final = 2048
@@ -1703,8 +1703,8 @@ if sys.version_info >= (3, 10) and sys.platform == "linux":
17031703
src: FileDescriptor,
17041704
dst: FileDescriptor,
17051705
count: int,
1706-
offset_src: int | None = ...,
1707-
offset_dst: int | None = ...,
1706+
offset_src: int | None = None,
1707+
offset_dst: int | None = None,
17081708
flags: int = 0,
17091709
) -> int: ...
17101710

stdlib/pstats.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Stats:
6161
sort_arg_dict_default: _SortArgDict
6262
def __init__(
6363
self,
64-
arg: None | str | Profile | _cProfile = ...,
64+
arg: None | str | Profile | _cProfile = None,
6565
/,
6666
*args: None | str | Profile | _cProfile | Self,
6767
stream: IO[Any] | None = None,

stdlib/sched.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
import time
23
from collections.abc import Callable
34
from typing import Any, ClassVar, NamedTuple, type_check_only
45
from typing_extensions import TypeAlias
@@ -32,7 +33,9 @@ class scheduler:
3233
timefunc: Callable[[], float]
3334
delayfunc: Callable[[float], object]
3435

35-
def __init__(self, timefunc: Callable[[], float] = ..., delayfunc: Callable[[float], object] = ...) -> None: ...
36+
def __init__(
37+
self, timefunc: Callable[[], float] = time.monotonic, delayfunc: Callable[[float], object] = time.sleep
38+
) -> None: ...
3639
def enterabs(
3740
self, time: float, priority: Any, action: _ActionCallback, argument: tuple[Any, ...] = (), kwargs: dict[str, Any] = ...
3841
) -> Event: ...

0 commit comments

Comments
 (0)