Skip to content

Commit 53747b2

Browse files
authored
Stdlib: add 'obvious' default values (#9688)
1 parent 6078927 commit 53747b2

17 files changed

+104
-104
lines changed

stdlib/asyncio/events.pyi

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -524,11 +524,11 @@ class AbstractEventLoop:
524524
stdin: int | IO[Any] | None = -1,
525525
stdout: int | IO[Any] | None = -1,
526526
stderr: int | IO[Any] | None = -1,
527-
universal_newlines: Literal[False] = ...,
528-
shell: Literal[True] = ...,
529-
bufsize: Literal[0] = ...,
530-
encoding: None = ...,
531-
errors: None = ...,
527+
universal_newlines: Literal[False] = False,
528+
shell: Literal[True] = True,
529+
bufsize: Literal[0] = 0,
530+
encoding: None = None,
531+
errors: None = None,
532532
text: Literal[False, None] = ...,
533533
**kwargs: Any,
534534
) -> tuple[SubprocessTransport, _ProtocolT]: ...
@@ -541,11 +541,11 @@ class AbstractEventLoop:
541541
stdin: int | IO[Any] | None = -1,
542542
stdout: int | IO[Any] | None = -1,
543543
stderr: int | IO[Any] | None = -1,
544-
universal_newlines: Literal[False] = ...,
545-
shell: Literal[False] = ...,
546-
bufsize: Literal[0] = ...,
547-
encoding: None = ...,
548-
errors: None = ...,
544+
universal_newlines: Literal[False] = False,
545+
shell: Literal[False] = False,
546+
bufsize: Literal[0] = 0,
547+
encoding: None = None,
548+
errors: None = None,
549549
**kwargs: Any,
550550
) -> tuple[SubprocessTransport, _ProtocolT]: ...
551551
@abstractmethod

stdlib/asyncio/subprocess.pyi

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ if sys.version_info >= (3, 11):
4949
limit: int = 65536,
5050
*,
5151
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
52-
universal_newlines: Literal[False] = ...,
53-
shell: Literal[True] = ...,
54-
bufsize: Literal[0] = ...,
55-
encoding: None = ...,
56-
errors: None = ...,
52+
universal_newlines: Literal[False] = False,
53+
shell: Literal[True] = True,
54+
bufsize: Literal[0] = 0,
55+
encoding: None = None,
56+
errors: None = None,
5757
text: Literal[False, None] = ...,
5858
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
5959
executable: StrOrBytesPath | None = ...,
@@ -81,11 +81,11 @@ if sys.version_info >= (3, 11):
8181
stderr: int | IO[Any] | None = None,
8282
limit: int = 65536,
8383
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
84-
universal_newlines: Literal[False] = ...,
85-
shell: Literal[True] = ...,
86-
bufsize: Literal[0] = ...,
87-
encoding: None = ...,
88-
errors: None = ...,
84+
universal_newlines: Literal[False] = False,
85+
shell: Literal[True] = True,
86+
bufsize: Literal[0] = 0,
87+
encoding: None = None,
88+
errors: None = None,
8989
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
9090
text: bool | None = ...,
9191
executable: StrOrBytesPath | None = ...,
@@ -115,11 +115,11 @@ elif sys.version_info >= (3, 10):
115115
limit: int = 65536,
116116
*,
117117
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
118-
universal_newlines: Literal[False] = ...,
119-
shell: Literal[True] = ...,
120-
bufsize: Literal[0] = ...,
121-
encoding: None = ...,
122-
errors: None = ...,
118+
universal_newlines: Literal[False] = False,
119+
shell: Literal[True] = True,
120+
bufsize: Literal[0] = 0,
121+
encoding: None = None,
122+
errors: None = None,
123123
text: Literal[False, None] = ...,
124124
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
125125
executable: StrOrBytesPath | None = ...,
@@ -146,11 +146,11 @@ elif sys.version_info >= (3, 10):
146146
stderr: int | IO[Any] | None = None,
147147
limit: int = 65536,
148148
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
149-
universal_newlines: Literal[False] = ...,
150-
shell: Literal[True] = ...,
151-
bufsize: Literal[0] = ...,
152-
encoding: None = ...,
153-
errors: None = ...,
149+
universal_newlines: Literal[False] = False,
150+
shell: Literal[True] = True,
151+
bufsize: Literal[0] = 0,
152+
encoding: None = None,
153+
errors: None = None,
154154
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
155155
text: bool | None = ...,
156156
executable: StrOrBytesPath | None = ...,
@@ -180,11 +180,11 @@ else: # >= 3.9
180180
limit: int = 65536,
181181
*,
182182
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
183-
universal_newlines: Literal[False] = ...,
184-
shell: Literal[True] = ...,
185-
bufsize: Literal[0] = ...,
186-
encoding: None = ...,
187-
errors: None = ...,
183+
universal_newlines: Literal[False] = False,
184+
shell: Literal[True] = True,
185+
bufsize: Literal[0] = 0,
186+
encoding: None = None,
187+
errors: None = None,
188188
text: Literal[False, None] = ...,
189189
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
190190
executable: StrOrBytesPath | None = ...,
@@ -211,11 +211,11 @@ else: # >= 3.9
211211
loop: events.AbstractEventLoop | None = None,
212212
limit: int = 65536,
213213
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
214-
universal_newlines: Literal[False] = ...,
215-
shell: Literal[True] = ...,
216-
bufsize: Literal[0] = ...,
217-
encoding: None = ...,
218-
errors: None = ...,
214+
universal_newlines: Literal[False] = False,
215+
shell: Literal[True] = True,
216+
bufsize: Literal[0] = 0,
217+
encoding: None = None,
218+
errors: None = None,
219219
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
220220
text: bool | None = ...,
221221
executable: StrOrBytesPath | None = ...,

stdlib/builtins.pyi

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,13 @@ class int:
257257
@overload
258258
def __pow__(self, __x: Literal[0], __modulo: None) -> Literal[1]: ...
259259
@overload
260-
def __pow__(self, __x: _PositiveInteger, __modulo: None = ...) -> int: ...
260+
def __pow__(self, __x: _PositiveInteger, __modulo: None = None) -> int: ...
261261
@overload
262-
def __pow__(self, __x: _NegativeInteger, __modulo: None = ...) -> float: ...
262+
def __pow__(self, __x: _NegativeInteger, __modulo: None = None) -> float: ...
263263
# positive x -> int; negative x -> float
264264
# return type must be Any as `int | float` causes too many false-positive errors
265265
@overload
266-
def __pow__(self, __x: int, __modulo: None = ...) -> Any: ...
266+
def __pow__(self, __x: int, __modulo: None = None) -> Any: ...
267267
@overload
268268
def __pow__(self, __x: int, __modulo: int) -> int: ...
269269
def __rpow__(self, __x: int, __mod: int | None = None) -> Any: ...
@@ -330,7 +330,7 @@ class float:
330330
def __rmod__(self, __x: float) -> float: ...
331331
def __rdivmod__(self, __x: float) -> tuple[float, float]: ...
332332
@overload
333-
def __rpow__(self, __x: _PositiveInteger, __modulo: None = ...) -> float: ...
333+
def __rpow__(self, __x: _PositiveInteger, __modulo: None = None) -> float: ...
334334
@overload
335335
def __rpow__(self, __x: _NegativeInteger, __mod: None = None) -> complex: ...
336336
# Returning `complex` for the general case gives too many false-positive errors.
@@ -1450,30 +1450,30 @@ class map(Iterator[_S], Generic[_S]):
14501450

14511451
@overload
14521452
def max(
1453-
__arg1: SupportsRichComparisonT, __arg2: SupportsRichComparisonT, *_args: SupportsRichComparisonT, key: None = ...
1453+
__arg1: SupportsRichComparisonT, __arg2: SupportsRichComparisonT, *_args: SupportsRichComparisonT, key: None = None
14541454
) -> SupportsRichComparisonT: ...
14551455
@overload
14561456
def max(__arg1: _T, __arg2: _T, *_args: _T, key: Callable[[_T], SupportsRichComparison]) -> _T: ...
14571457
@overload
1458-
def max(__iterable: Iterable[SupportsRichComparisonT], *, key: None = ...) -> SupportsRichComparisonT: ...
1458+
def max(__iterable: Iterable[SupportsRichComparisonT], *, key: None = None) -> SupportsRichComparisonT: ...
14591459
@overload
14601460
def max(__iterable: Iterable[_T], *, key: Callable[[_T], SupportsRichComparison]) -> _T: ...
14611461
@overload
1462-
def max(__iterable: Iterable[SupportsRichComparisonT], *, key: None = ..., default: _T) -> SupportsRichComparisonT | _T: ...
1462+
def max(__iterable: Iterable[SupportsRichComparisonT], *, key: None = None, default: _T) -> SupportsRichComparisonT | _T: ...
14631463
@overload
14641464
def max(__iterable: Iterable[_T1], *, key: Callable[[_T1], SupportsRichComparison], default: _T2) -> _T1 | _T2: ...
14651465
@overload
14661466
def min(
1467-
__arg1: SupportsRichComparisonT, __arg2: SupportsRichComparisonT, *_args: SupportsRichComparisonT, key: None = ...
1467+
__arg1: SupportsRichComparisonT, __arg2: SupportsRichComparisonT, *_args: SupportsRichComparisonT, key: None = None
14681468
) -> SupportsRichComparisonT: ...
14691469
@overload
14701470
def min(__arg1: _T, __arg2: _T, *_args: _T, key: Callable[[_T], SupportsRichComparison]) -> _T: ...
14711471
@overload
1472-
def min(__iterable: Iterable[SupportsRichComparisonT], *, key: None = ...) -> SupportsRichComparisonT: ...
1472+
def min(__iterable: Iterable[SupportsRichComparisonT], *, key: None = None) -> SupportsRichComparisonT: ...
14731473
@overload
14741474
def min(__iterable: Iterable[_T], *, key: Callable[[_T], SupportsRichComparison]) -> _T: ...
14751475
@overload
1476-
def min(__iterable: Iterable[SupportsRichComparisonT], *, key: None = ..., default: _T) -> SupportsRichComparisonT | _T: ...
1476+
def min(__iterable: Iterable[SupportsRichComparisonT], *, key: None = None, default: _T) -> SupportsRichComparisonT | _T: ...
14771477
@overload
14781478
def min(__iterable: Iterable[_T1], *, key: Callable[[_T1], SupportsRichComparison], default: _T2) -> _T1 | _T2: ...
14791479
@overload
@@ -1595,7 +1595,7 @@ class _SupportsPow2(Protocol[_E, _T_co]):
15951595
def __pow__(self, __other: _E) -> _T_co: ...
15961596

15971597
class _SupportsPow3NoneOnly(Protocol[_E, _T_co]):
1598-
def __pow__(self, __other: _E, __modulo: None = ...) -> _T_co: ...
1598+
def __pow__(self, __other: _E, __modulo: None = None) -> _T_co: ...
15991599

16001600
class _SupportsPow3(Protocol[_E, _M, _T_co]):
16011601
def __pow__(self, __other: _E, __modulo: _M) -> _T_co: ...

stdlib/functools.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ class _SingleDispatchCallable(Generic[_T]):
111111
# @fun.register(complex)
112112
# def _(arg, verbose=False): ...
113113
@overload
114-
def register(self, cls: type[Any], func: None = ...) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
114+
def register(self, cls: type[Any], func: None = None) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
115115
# @fun.register
116116
# def _(arg: int, verbose=False):
117117
@overload
118-
def register(self, cls: Callable[..., _T], func: None = ...) -> Callable[..., _T]: ...
118+
def register(self, cls: Callable[..., _T], func: None = None) -> Callable[..., _T]: ...
119119
# fun.register(int, lambda x: x)
120120
@overload
121121
def register(self, cls: type[Any], func: Callable[..., _T]) -> Callable[..., _T]: ...

stdlib/importlib/abc.pyi

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ if sys.version_info >= (3, 9):
133133
@overload
134134
@abstractmethod
135135
def open(
136-
self, mode: OpenBinaryMode, buffering: Literal[0], encoding: None = ..., errors: None = ..., newline: None = ...
136+
self, mode: OpenBinaryMode, buffering: Literal[0], encoding: None = None, errors: None = None, newline: None = None
137137
) -> FileIO: ...
138138
# Buffering is on: return BufferedRandom, BufferedReader, or BufferedWriter
139139
@overload
@@ -142,35 +142,35 @@ if sys.version_info >= (3, 9):
142142
self,
143143
mode: OpenBinaryModeUpdating,
144144
buffering: Literal[-1, 1] = ...,
145-
encoding: None = ...,
146-
errors: None = ...,
147-
newline: None = ...,
145+
encoding: None = None,
146+
errors: None = None,
147+
newline: None = None,
148148
) -> BufferedRandom: ...
149149
@overload
150150
@abstractmethod
151151
def open(
152152
self,
153153
mode: OpenBinaryModeWriting,
154154
buffering: Literal[-1, 1] = ...,
155-
encoding: None = ...,
156-
errors: None = ...,
157-
newline: None = ...,
155+
encoding: None = None,
156+
errors: None = None,
157+
newline: None = None,
158158
) -> BufferedWriter: ...
159159
@overload
160160
@abstractmethod
161161
def open(
162162
self,
163163
mode: OpenBinaryModeReading,
164164
buffering: Literal[-1, 1] = ...,
165-
encoding: None = ...,
166-
errors: None = ...,
167-
newline: None = ...,
165+
encoding: None = None,
166+
errors: None = None,
167+
newline: None = None,
168168
) -> BufferedReader: ...
169169
# Buffering cannot be determined: fall back to BinaryIO
170170
@overload
171171
@abstractmethod
172172
def open(
173-
self, mode: OpenBinaryMode, buffering: int = ..., encoding: None = ..., errors: None = ..., newline: None = ...
173+
self, mode: OpenBinaryMode, buffering: int = ..., encoding: None = None, errors: None = None, newline: None = None
174174
) -> BinaryIO: ...
175175
# Fallback if mode is not specified
176176
@overload

stdlib/importlib/metadata/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class Distribution:
132132
@overload
133133
@classmethod
134134
def discover(
135-
cls, *, context: None = ..., name: str | None = ..., path: list[str] = ..., **kwargs: Any
135+
cls, *, context: None = None, name: str | None = ..., path: list[str] = ..., **kwargs: Any
136136
) -> Iterable[Distribution]: ...
137137
@staticmethod
138138
def at(path: StrPath) -> PathDistribution: ...
@@ -185,7 +185,7 @@ def distribution(distribution_name: str) -> Distribution: ...
185185
def distributions(*, context: DistributionFinder.Context) -> Iterable[Distribution]: ...
186186
@overload
187187
def distributions(
188-
*, context: None = ..., name: str | None = ..., path: list[str] = ..., **kwargs: Any
188+
*, context: None = None, name: str | None = ..., path: list[str] = ..., **kwargs: Any
189189
) -> Iterable[Distribution]: ...
190190

191191
if sys.version_info >= (3, 10):

stdlib/itertools.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class repeat(Iterator[_T], Generic[_T]):
5151
class accumulate(Iterator[_T], Generic[_T]):
5252
if sys.version_info >= (3, 8):
5353
@overload
54-
def __init__(self, iterable: Iterable[_T], func: None = ..., *, initial: _T | None = ...) -> None: ...
54+
def __init__(self, iterable: Iterable[_T], func: None = None, *, initial: _T | None = ...) -> None: ...
5555
@overload
5656
def __init__(self, iterable: Iterable[_S], func: Callable[[_T, _S], _T], *, initial: _T | None = ...) -> None: ...
5757
else:
@@ -87,7 +87,7 @@ class filterfalse(Iterator[_T], Generic[_T]):
8787

8888
class groupby(Iterator[tuple[_T, Iterator[_S]]], Generic[_T, _S]):
8989
@overload
90-
def __new__(cls, iterable: Iterable[_T1], key: None = ...) -> groupby[_T1, _T1]: ...
90+
def __new__(cls, iterable: Iterable[_T1], key: None = None) -> groupby[_T1, _T1]: ...
9191
@overload
9292
def __new__(cls, iterable: Iterable[_T1], key: Callable[[_T1], _T2]) -> groupby[_T2, _T1]: ...
9393
def __iter__(self: Self) -> Self: ...

stdlib/multiprocessing/managers.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class BaseListProxy(BaseProxy, MutableSequence[_T]):
111111
# Use BaseListProxy[SupportsRichComparisonT] for the first overload rather than [SupportsRichComparison]
112112
# to work around invariance
113113
@overload
114-
def sort(self: BaseListProxy[SupportsRichComparisonT], *, key: None = ..., reverse: bool = ...) -> None: ...
114+
def sort(self: BaseListProxy[SupportsRichComparisonT], *, key: None = None, reverse: bool = ...) -> None: ...
115115
@overload
116116
def sort(self, *, key: Callable[[_T], SupportsRichComparison], reverse: bool = ...) -> None: ...
117117

stdlib/os/__init__.pyi

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,8 @@ def fdopen(
530530
mode: OpenBinaryMode,
531531
buffering: Literal[0],
532532
encoding: None = None,
533-
errors: None = ...,
534-
newline: None = ...,
533+
errors: None = None,
534+
newline: None = None,
535535
closefd: bool = ...,
536536
opener: _Opener | None = ...,
537537
) -> FileIO: ...
@@ -541,8 +541,8 @@ def fdopen(
541541
mode: OpenBinaryModeUpdating,
542542
buffering: Literal[-1, 1] = -1,
543543
encoding: None = None,
544-
errors: None = ...,
545-
newline: None = ...,
544+
errors: None = None,
545+
newline: None = None,
546546
closefd: bool = ...,
547547
opener: _Opener | None = ...,
548548
) -> BufferedRandom: ...
@@ -552,8 +552,8 @@ def fdopen(
552552
mode: OpenBinaryModeWriting,
553553
buffering: Literal[-1, 1] = -1,
554554
encoding: None = None,
555-
errors: None = ...,
556-
newline: None = ...,
555+
errors: None = None,
556+
newline: None = None,
557557
closefd: bool = ...,
558558
opener: _Opener | None = ...,
559559
) -> BufferedWriter: ...
@@ -563,8 +563,8 @@ def fdopen(
563563
mode: OpenBinaryModeReading,
564564
buffering: Literal[-1, 1] = -1,
565565
encoding: None = None,
566-
errors: None = ...,
567-
newline: None = ...,
566+
errors: None = None,
567+
newline: None = None,
568568
closefd: bool = ...,
569569
opener: _Opener | None = ...,
570570
) -> BufferedReader: ...
@@ -574,8 +574,8 @@ def fdopen(
574574
mode: OpenBinaryMode,
575575
buffering: int = -1,
576576
encoding: None = None,
577-
errors: None = ...,
578-
newline: None = ...,
577+
errors: None = None,
578+
newline: None = None,
579579
closefd: bool = ...,
580580
opener: _Opener | None = ...,
581581
) -> BinaryIO: ...

stdlib/re.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class Match(Generic[AnyStr]):
7272
def expand(self, template: AnyStr) -> AnyStr: ...
7373
# group() returns "AnyStr" or "AnyStr | None", depending on the pattern.
7474
@overload
75-
def group(self, __group: Literal[0] = ...) -> AnyStr: ...
75+
def group(self, __group: Literal[0] = 0) -> AnyStr: ...
7676
@overload
7777
def group(self, __group: str | int) -> AnyStr | Any: ...
7878
@overload

stdlib/signal.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,4 @@ def set_wakeup_fd(fd: int, *, warn_on_full_buffer: bool = ...) -> int: ...
178178

179179
if sys.version_info >= (3, 9):
180180
if sys.platform == "linux":
181-
def pidfd_send_signal(__pidfd: int, __sig: int, __siginfo: None = ..., __flags: int = ...) -> None: ...
181+
def pidfd_send_signal(__pidfd: int, __sig: int, __siginfo: None = None, __flags: int = ...) -> None: ...

0 commit comments

Comments
 (0)