Stdlib: add 'obvious' default values (#9688)

This commit is contained in:
Alex Waygood
2023-02-07 12:00:40 +00:00
committed by GitHub
parent 60789273a2
commit 53747b264e
17 changed files with 104 additions and 104 deletions

View File

@@ -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]: ...
@@ -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

View File

@@ -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 = ...,
@@ -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 = ...,
@@ -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 = ...,
@@ -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 = ...,
@@ -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 = ...,
@@ -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 = ...,

View File

@@ -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: ...
@@ -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.
@@ -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
@@ -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: ...

View File

@@ -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]: ...

View File

@@ -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
@@ -142,9 +142,9 @@ 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
@@ -152,9 +152,9 @@ if sys.version_info >= (3, 9):
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
@@ -162,15 +162,15 @@ if sys.version_info >= (3, 9):
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

View File

@@ -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: ...
@@ -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):

View File

@@ -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:
@@ -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: ...

View File

@@ -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: ...

View File

@@ -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: ...
@@ -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: ...
@@ -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: ...
@@ -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: ...
@@ -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: ...

View File

@@ -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

View File

@@ -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: ...

View File

@@ -68,7 +68,7 @@ def quotedata(data: str) -> str: ...
class _AuthObject(Protocol):
@overload
def __call__(self, challenge: None = ...) -> str | None: ...
def __call__(self, challenge: None = None) -> str | None: ...
@overload
def __call__(self, challenge: bytes) -> str: ...

View File

@@ -324,7 +324,7 @@ class Connection:
def create_function(self, name: str, num_params: int, func: Callable[..., _SqliteData] | None) -> None: ...
@overload
def cursor(self, cursorClass: None = ...) -> Cursor: ...
def cursor(self, cursorClass: None = None) -> Cursor: ...
@overload
def cursor(self, cursorClass: Callable[[], _CursorT]) -> _CursorT: ...
def execute(self, sql: str, parameters: _Parameters = ...) -> Cursor: ...

View File

@@ -257,8 +257,8 @@ if sys.version_info >= (3, 11):
*,
capture_output: bool = False,
check: bool = False,
encoding: None = ...,
errors: None = ...,
encoding: None = None,
errors: None = None,
input: ReadableBuffer | None = None,
text: Literal[None, False] = ...,
timeout: float | None = None,
@@ -461,8 +461,8 @@ elif sys.version_info >= (3, 10):
*,
capture_output: bool = False,
check: bool = False,
encoding: None = ...,
errors: None = ...,
encoding: None = None,
errors: None = None,
input: ReadableBuffer | None = None,
text: Literal[None, False] = ...,
timeout: float | None = None,
@@ -659,8 +659,8 @@ elif sys.version_info >= (3, 9):
*,
capture_output: bool = False,
check: bool = False,
encoding: None = ...,
errors: None = ...,
encoding: None = None,
errors: None = None,
input: ReadableBuffer | None = None,
text: Literal[None, False] = ...,
timeout: float | None = None,
@@ -838,8 +838,8 @@ else:
*,
capture_output: bool = False,
check: bool = False,
encoding: None = ...,
errors: None = ...,
encoding: None = None,
errors: None = None,
input: ReadableBuffer | None = None,
text: Literal[None, False] = ...,
timeout: float | None = None,
@@ -1251,8 +1251,8 @@ if sys.version_info >= (3, 11):
*,
timeout: float | None = None,
input: _InputString | None = ...,
encoding: None = ...,
errors: None = ...,
encoding: None = None,
errors: None = None,
text: Literal[None, False] = ...,
user: str | int | None = ...,
group: str | int | None = ...,
@@ -1437,8 +1437,8 @@ elif sys.version_info >= (3, 10):
*,
timeout: float | None = None,
input: _InputString | None = ...,
encoding: None = ...,
errors: None = ...,
encoding: None = None,
errors: None = None,
text: Literal[None, False] = ...,
user: str | int | None = ...,
group: str | int | None = ...,
@@ -1617,8 +1617,8 @@ elif sys.version_info >= (3, 9):
*,
timeout: float | None = None,
input: _InputString | None = ...,
encoding: None = ...,
errors: None = ...,
encoding: None = None,
errors: None = None,
text: Literal[None, False] = ...,
user: str | int | None = ...,
group: str | int | None = ...,
@@ -1778,8 +1778,8 @@ else:
*,
timeout: float | None = None,
input: _InputString | None = ...,
encoding: None = ...,
errors: None = ...,
encoding: None = None,
errors: None = None,
text: Literal[None, False] = ...,
) -> bytes: ...
@overload

View File

@@ -363,7 +363,7 @@ class GeneratorType(Generator[_T_co, _T_contra, _V_co]):
self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...
) -> _T_co: ...
@overload
def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ...
def throw(self, __typ: BaseException, __val: None = None, __tb: TracebackType | None = ...) -> _T_co: ...
@final
class AsyncGeneratorType(AsyncGenerator[_T_co, _T_contra]):
@@ -379,7 +379,7 @@ class AsyncGeneratorType(AsyncGenerator[_T_co, _T_contra]):
self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...
) -> _T_co: ...
@overload
async def athrow(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ...
async def athrow(self, __typ: BaseException, __val: None = None, __tb: TracebackType | None = ...) -> _T_co: ...
def aclose(self) -> Coroutine[Any, Any, None]: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
@@ -402,7 +402,7 @@ class CoroutineType(Coroutine[_T_co, _T_contra, _V_co]):
self, __typ: type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...
) -> _T_co: ...
@overload
def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ...
def throw(self, __typ: BaseException, __val: None = None, __tb: TracebackType | None = ...) -> _T_co: ...
class _StaticFunctionType:
# Fictional type to correct the type of MethodType.__func__.

View File

@@ -784,7 +784,7 @@ class NamedTuple(tuple[Any, ...]):
@overload
def __init__(self, typename: str, fields: Iterable[tuple[str, Any]] = ...) -> None: ...
@overload
def __init__(self, typename: str, fields: None = ..., **kwargs: Any) -> None: ...
def __init__(self, typename: str, fields: None = None, **kwargs: Any) -> None: ...
@classmethod
def _make(cls: Type[_T], iterable: Iterable[Any]) -> _T: ...
if sys.version_info >= (3, 8):

View File

@@ -242,7 +242,7 @@ else:
@overload
def __init__(self, typename: str, fields: Iterable[tuple[str, Any]] = ...) -> None: ...
@overload
def __init__(self, typename: str, fields: None = ..., **kwargs: Any) -> None: ...
def __init__(self, typename: str, fields: None = None, **kwargs: Any) -> None: ...
@classmethod
def _make(cls: type[_typeshed.Self], iterable: Iterable[Any]) -> _typeshed.Self: ...
if sys.version_info >= (3, 8):