Skip to content

Stdlib: add 'obvious' default values #9688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions stdlib/asyncio/events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,11 @@ class AbstractEventLoop:
stdin: int | IO[Any] | None = -1,
stdout: int | IO[Any] | None = -1,
stderr: int | IO[Any] | None = -1,
universal_newlines: Literal[False] = ...,
shell: Literal[True] = ...,
bufsize: Literal[0] = ...,
encoding: None = ...,
errors: None = ...,
universal_newlines: Literal[False] = False,
shell: Literal[True] = True,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
text: Literal[False, None] = ...,
**kwargs: Any,
) -> tuple[SubprocessTransport, _ProtocolT]: ...
Expand All @@ -541,11 +541,11 @@ class AbstractEventLoop:
stdin: int | IO[Any] | None = -1,
stdout: int | IO[Any] | None = -1,
stderr: int | IO[Any] | None = -1,
universal_newlines: Literal[False] = ...,
shell: Literal[False] = ...,
bufsize: Literal[0] = ...,
encoding: None = ...,
errors: None = ...,
universal_newlines: Literal[False] = False,
shell: Literal[False] = False,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
**kwargs: Any,
) -> tuple[SubprocessTransport, _ProtocolT]: ...
@abstractmethod
Expand Down
60 changes: 30 additions & 30 deletions stdlib/asyncio/subprocess.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ if sys.version_info >= (3, 11):
limit: int = 65536,
*,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
universal_newlines: Literal[False] = ...,
shell: Literal[True] = ...,
bufsize: Literal[0] = ...,
encoding: None = ...,
errors: None = ...,
universal_newlines: Literal[False] = False,
shell: Literal[True] = True,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
text: Literal[False, None] = ...,
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
executable: StrOrBytesPath | None = ...,
Expand Down Expand Up @@ -81,11 +81,11 @@ if sys.version_info >= (3, 11):
stderr: int | IO[Any] | None = None,
limit: int = 65536,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
universal_newlines: Literal[False] = ...,
shell: Literal[True] = ...,
bufsize: Literal[0] = ...,
encoding: None = ...,
errors: None = ...,
universal_newlines: Literal[False] = False,
shell: Literal[True] = True,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
text: bool | None = ...,
executable: StrOrBytesPath | None = ...,
Expand Down Expand Up @@ -115,11 +115,11 @@ elif sys.version_info >= (3, 10):
limit: int = 65536,
*,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
universal_newlines: Literal[False] = ...,
shell: Literal[True] = ...,
bufsize: Literal[0] = ...,
encoding: None = ...,
errors: None = ...,
universal_newlines: Literal[False] = False,
shell: Literal[True] = True,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
text: Literal[False, None] = ...,
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
executable: StrOrBytesPath | None = ...,
Expand All @@ -146,11 +146,11 @@ elif sys.version_info >= (3, 10):
stderr: int | IO[Any] | None = None,
limit: int = 65536,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
universal_newlines: Literal[False] = ...,
shell: Literal[True] = ...,
bufsize: Literal[0] = ...,
encoding: None = ...,
errors: None = ...,
universal_newlines: Literal[False] = False,
shell: Literal[True] = True,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
text: bool | None = ...,
executable: StrOrBytesPath | None = ...,
Expand Down Expand Up @@ -180,11 +180,11 @@ else: # >= 3.9
limit: int = 65536,
*,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
universal_newlines: Literal[False] = ...,
shell: Literal[True] = ...,
bufsize: Literal[0] = ...,
encoding: None = ...,
errors: None = ...,
universal_newlines: Literal[False] = False,
shell: Literal[True] = True,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
text: Literal[False, None] = ...,
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
executable: StrOrBytesPath | None = ...,
Expand All @@ -211,11 +211,11 @@ else: # >= 3.9
loop: events.AbstractEventLoop | None = None,
limit: int = 65536,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
universal_newlines: Literal[False] = ...,
shell: Literal[True] = ...,
bufsize: Literal[0] = ...,
encoding: None = ...,
errors: None = ...,
universal_newlines: Literal[False] = False,
shell: Literal[True] = True,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
text: bool | None = ...,
executable: StrOrBytesPath | None = ...,
Expand Down
22 changes: 11 additions & 11 deletions stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,13 @@ class int:
@overload
def __pow__(self, __x: Literal[0], __modulo: None) -> Literal[1]: ...
@overload
def __pow__(self, __x: _PositiveInteger, __modulo: None = ...) -> int: ...
def __pow__(self, __x: _PositiveInteger, __modulo: None = None) -> int: ...
@overload
def __pow__(self, __x: _NegativeInteger, __modulo: None = ...) -> float: ...
def __pow__(self, __x: _NegativeInteger, __modulo: None = None) -> float: ...
# positive x -> int; negative x -> float
# return type must be Any as `int | float` causes too many false-positive errors
@overload
def __pow__(self, __x: int, __modulo: None = ...) -> Any: ...
def __pow__(self, __x: int, __modulo: None = None) -> Any: ...
@overload
def __pow__(self, __x: int, __modulo: int) -> int: ...
def __rpow__(self, __x: int, __mod: int | None = None) -> Any: ...
Expand Down Expand Up @@ -330,7 +330,7 @@ class float:
def __rmod__(self, __x: float) -> float: ...
def __rdivmod__(self, __x: float) -> tuple[float, float]: ...
@overload
def __rpow__(self, __x: _PositiveInteger, __modulo: None = ...) -> float: ...
def __rpow__(self, __x: _PositiveInteger, __modulo: None = None) -> float: ...
@overload
def __rpow__(self, __x: _NegativeInteger, __mod: None = None) -> complex: ...
# Returning `complex` for the general case gives too many false-positive errors.
Expand Down Expand Up @@ -1450,30 +1450,30 @@ class map(Iterator[_S], Generic[_S]):

@overload
def max(
__arg1: SupportsRichComparisonT, __arg2: SupportsRichComparisonT, *_args: SupportsRichComparisonT, key: None = ...
__arg1: SupportsRichComparisonT, __arg2: SupportsRichComparisonT, *_args: SupportsRichComparisonT, key: None = None
) -> SupportsRichComparisonT: ...
@overload
def max(__arg1: _T, __arg2: _T, *_args: _T, key: Callable[[_T], SupportsRichComparison]) -> _T: ...
@overload
def max(__iterable: Iterable[SupportsRichComparisonT], *, key: None = ...) -> SupportsRichComparisonT: ...
def max(__iterable: Iterable[SupportsRichComparisonT], *, key: None = None) -> SupportsRichComparisonT: ...
@overload
def max(__iterable: Iterable[_T], *, key: Callable[[_T], SupportsRichComparison]) -> _T: ...
@overload
def max(__iterable: Iterable[SupportsRichComparisonT], *, key: None = ..., default: _T) -> SupportsRichComparisonT | _T: ...
def max(__iterable: Iterable[SupportsRichComparisonT], *, key: None = None, default: _T) -> SupportsRichComparisonT | _T: ...
@overload
def max(__iterable: Iterable[_T1], *, key: Callable[[_T1], SupportsRichComparison], default: _T2) -> _T1 | _T2: ...
@overload
def min(
__arg1: SupportsRichComparisonT, __arg2: SupportsRichComparisonT, *_args: SupportsRichComparisonT, key: None = ...
__arg1: SupportsRichComparisonT, __arg2: SupportsRichComparisonT, *_args: SupportsRichComparisonT, key: None = None
) -> SupportsRichComparisonT: ...
@overload
def min(__arg1: _T, __arg2: _T, *_args: _T, key: Callable[[_T], SupportsRichComparison]) -> _T: ...
@overload
def min(__iterable: Iterable[SupportsRichComparisonT], *, key: None = ...) -> SupportsRichComparisonT: ...
def min(__iterable: Iterable[SupportsRichComparisonT], *, key: None = None) -> SupportsRichComparisonT: ...
@overload
def min(__iterable: Iterable[_T], *, key: Callable[[_T], SupportsRichComparison]) -> _T: ...
@overload
def min(__iterable: Iterable[SupportsRichComparisonT], *, key: None = ..., default: _T) -> SupportsRichComparisonT | _T: ...
def min(__iterable: Iterable[SupportsRichComparisonT], *, key: None = None, default: _T) -> SupportsRichComparisonT | _T: ...
@overload
def min(__iterable: Iterable[_T1], *, key: Callable[[_T1], SupportsRichComparison], default: _T2) -> _T1 | _T2: ...
@overload
Expand Down Expand Up @@ -1595,7 +1595,7 @@ class _SupportsPow2(Protocol[_E, _T_co]):
def __pow__(self, __other: _E) -> _T_co: ...

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

class _SupportsPow3(Protocol[_E, _M, _T_co]):
def __pow__(self, __other: _E, __modulo: _M) -> _T_co: ...
Expand Down
4 changes: 2 additions & 2 deletions stdlib/functools.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ class _SingleDispatchCallable(Generic[_T]):
# @fun.register(complex)
# def _(arg, verbose=False): ...
@overload
def register(self, cls: type[Any], func: None = ...) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
def register(self, cls: type[Any], func: None = None) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
# @fun.register
# def _(arg: int, verbose=False):
@overload
def register(self, cls: Callable[..., _T], func: None = ...) -> Callable[..., _T]: ...
def register(self, cls: Callable[..., _T], func: None = None) -> Callable[..., _T]: ...
# fun.register(int, lambda x: x)
@overload
def register(self, cls: type[Any], func: Callable[..., _T]) -> Callable[..., _T]: ...
Expand Down
22 changes: 11 additions & 11 deletions stdlib/importlib/abc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ if sys.version_info >= (3, 9):
@overload
@abstractmethod
def open(
self, mode: OpenBinaryMode, buffering: Literal[0], encoding: None = ..., errors: None = ..., newline: None = ...
self, mode: OpenBinaryMode, buffering: Literal[0], encoding: None = None, errors: None = None, newline: None = None
) -> FileIO: ...
# Buffering is on: return BufferedRandom, BufferedReader, or BufferedWriter
@overload
Expand All @@ -142,35 +142,35 @@ if sys.version_info >= (3, 9):
self,
mode: OpenBinaryModeUpdating,
buffering: Literal[-1, 1] = ...,
encoding: None = ...,
errors: None = ...,
newline: None = ...,
encoding: None = None,
errors: None = None,
newline: None = None,
) -> BufferedRandom: ...
@overload
@abstractmethod
def open(
self,
mode: OpenBinaryModeWriting,
buffering: Literal[-1, 1] = ...,
encoding: None = ...,
errors: None = ...,
newline: None = ...,
encoding: None = None,
errors: None = None,
newline: None = None,
) -> BufferedWriter: ...
@overload
@abstractmethod
def open(
self,
mode: OpenBinaryModeReading,
buffering: Literal[-1, 1] = ...,
encoding: None = ...,
errors: None = ...,
newline: None = ...,
encoding: None = None,
errors: None = None,
newline: None = None,
) -> BufferedReader: ...
# Buffering cannot be determined: fall back to BinaryIO
@overload
@abstractmethod
def open(
self, mode: OpenBinaryMode, buffering: int = ..., encoding: None = ..., errors: None = ..., newline: None = ...
self, mode: OpenBinaryMode, buffering: int = ..., encoding: None = None, errors: None = None, newline: None = None
) -> BinaryIO: ...
# Fallback if mode is not specified
@overload
Expand Down
4 changes: 2 additions & 2 deletions stdlib/importlib/metadata/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class Distribution:
@overload
@classmethod
def discover(
cls, *, context: None = ..., name: str | None = ..., path: list[str] = ..., **kwargs: Any
cls, *, context: None = None, name: str | None = ..., path: list[str] = ..., **kwargs: Any
) -> Iterable[Distribution]: ...
@staticmethod
def at(path: StrPath) -> PathDistribution: ...
Expand Down Expand Up @@ -185,7 +185,7 @@ def distribution(distribution_name: str) -> Distribution: ...
def distributions(*, context: DistributionFinder.Context) -> Iterable[Distribution]: ...
@overload
def distributions(
*, context: None = ..., name: str | None = ..., path: list[str] = ..., **kwargs: Any
*, context: None = None, name: str | None = ..., path: list[str] = ..., **kwargs: Any
) -> Iterable[Distribution]: ...

if sys.version_info >= (3, 10):
Expand Down
4 changes: 2 additions & 2 deletions stdlib/itertools.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class repeat(Iterator[_T], Generic[_T]):
class accumulate(Iterator[_T], Generic[_T]):
if sys.version_info >= (3, 8):
@overload
def __init__(self, iterable: Iterable[_T], func: None = ..., *, initial: _T | None = ...) -> None: ...
def __init__(self, iterable: Iterable[_T], func: None = None, *, initial: _T | None = ...) -> None: ...
@overload
def __init__(self, iterable: Iterable[_S], func: Callable[[_T, _S], _T], *, initial: _T | None = ...) -> None: ...
else:
Expand Down Expand Up @@ -87,7 +87,7 @@ class filterfalse(Iterator[_T], Generic[_T]):

class groupby(Iterator[tuple[_T, Iterator[_S]]], Generic[_T, _S]):
@overload
def __new__(cls, iterable: Iterable[_T1], key: None = ...) -> groupby[_T1, _T1]: ...
def __new__(cls, iterable: Iterable[_T1], key: None = None) -> groupby[_T1, _T1]: ...
@overload
def __new__(cls, iterable: Iterable[_T1], key: Callable[[_T1], _T2]) -> groupby[_T2, _T1]: ...
def __iter__(self: Self) -> Self: ...
Expand Down
2 changes: 1 addition & 1 deletion stdlib/multiprocessing/managers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class BaseListProxy(BaseProxy, MutableSequence[_T]):
# Use BaseListProxy[SupportsRichComparisonT] for the first overload rather than [SupportsRichComparison]
# to work around invariance
@overload
def sort(self: BaseListProxy[SupportsRichComparisonT], *, key: None = ..., reverse: bool = ...) -> None: ...
def sort(self: BaseListProxy[SupportsRichComparisonT], *, key: None = None, reverse: bool = ...) -> None: ...
@overload
def sort(self, *, key: Callable[[_T], SupportsRichComparison], reverse: bool = ...) -> None: ...

Expand Down
20 changes: 10 additions & 10 deletions stdlib/os/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,8 @@ def fdopen(
mode: OpenBinaryMode,
buffering: Literal[0],
encoding: None = None,
errors: None = ...,
newline: None = ...,
errors: None = None,
newline: None = None,
closefd: bool = ...,
opener: _Opener | None = ...,
) -> FileIO: ...
Expand All @@ -541,8 +541,8 @@ def fdopen(
mode: OpenBinaryModeUpdating,
buffering: Literal[-1, 1] = -1,
encoding: None = None,
errors: None = ...,
newline: None = ...,
errors: None = None,
newline: None = None,
closefd: bool = ...,
opener: _Opener | None = ...,
) -> BufferedRandom: ...
Expand All @@ -552,8 +552,8 @@ def fdopen(
mode: OpenBinaryModeWriting,
buffering: Literal[-1, 1] = -1,
encoding: None = None,
errors: None = ...,
newline: None = ...,
errors: None = None,
newline: None = None,
closefd: bool = ...,
opener: _Opener | None = ...,
) -> BufferedWriter: ...
Expand All @@ -563,8 +563,8 @@ def fdopen(
mode: OpenBinaryModeReading,
buffering: Literal[-1, 1] = -1,
encoding: None = None,
errors: None = ...,
newline: None = ...,
errors: None = None,
newline: None = None,
closefd: bool = ...,
opener: _Opener | None = ...,
) -> BufferedReader: ...
Expand All @@ -574,8 +574,8 @@ def fdopen(
mode: OpenBinaryMode,
buffering: int = -1,
encoding: None = None,
errors: None = ...,
newline: None = ...,
errors: None = None,
newline: None = None,
closefd: bool = ...,
opener: _Opener | None = ...,
) -> BinaryIO: ...
Expand Down
2 changes: 1 addition & 1 deletion stdlib/re.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Match(Generic[AnyStr]):
def expand(self, template: AnyStr) -> AnyStr: ...
# group() returns "AnyStr" or "AnyStr | None", depending on the pattern.
@overload
def group(self, __group: Literal[0] = ...) -> AnyStr: ...
def group(self, __group: Literal[0] = 0) -> AnyStr: ...
@overload
def group(self, __group: str | int) -> AnyStr | Any: ...
@overload
Expand Down
2 changes: 1 addition & 1 deletion stdlib/signal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,4 @@ def set_wakeup_fd(fd: int, *, warn_on_full_buffer: bool = ...) -> int: ...

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