Add more defaults to the stdlib (#9606)

Continuing work towards #8988.

The first five commits were created using stubdefaulter on various Python versions; the following commits were all created manually by me to fix various problems. The main things this adds that weren't present in #9501 are:

- Defaults in Windows-only modules and Windows-only branches (because I'm running a Windows machine)
- Defaults in non-py311 branches
- Defaults for float parameters
- Defaults for overloads
This commit is contained in:
Alex Waygood
2023-01-29 01:51:23 +00:00
committed by GitHub
parent 25e02db42c
commit 33a62ae42d
150 changed files with 2761 additions and 2704 deletions

View File

@@ -47,18 +47,18 @@ class ExecError(OSError): ...
class ReadError(OSError): ...
class RegistryError(Exception): ...
def copyfileobj(fsrc: SupportsRead[AnyStr], fdst: SupportsWrite[AnyStr], length: int = 0) -> None: ...
def copyfileobj(fsrc: SupportsRead[AnyStr], fdst: SupportsWrite[AnyStr], length: int = ...) -> None: ...
def copyfile(src: StrOrBytesPath, dst: _StrOrBytesPathT, *, follow_symlinks: bool = True) -> _StrOrBytesPathT: ...
def copymode(src: StrOrBytesPath, dst: StrOrBytesPath, *, follow_symlinks: bool = True) -> None: ...
def copystat(src: StrOrBytesPath, dst: StrOrBytesPath, *, follow_symlinks: bool = True) -> None: ...
@overload
def copy(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> _PathReturn: ...
def copy(src: StrPath, dst: StrPath, *, follow_symlinks: bool = True) -> _PathReturn: ...
@overload
def copy(src: BytesPath, dst: BytesPath, *, follow_symlinks: bool = ...) -> _PathReturn: ...
def copy(src: BytesPath, dst: BytesPath, *, follow_symlinks: bool = True) -> _PathReturn: ...
@overload
def copy2(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> _PathReturn: ...
def copy2(src: StrPath, dst: StrPath, *, follow_symlinks: bool = True) -> _PathReturn: ...
@overload
def copy2(src: BytesPath, dst: BytesPath, *, follow_symlinks: bool = ...) -> _PathReturn: ...
def copy2(src: BytesPath, dst: BytesPath, *, follow_symlinks: bool = True) -> _PathReturn: ...
def ignore_patterns(*patterns: StrPath) -> Callable[[Any, list[str]], set[str]]: ...
if sys.version_info >= (3, 8):
@@ -76,10 +76,10 @@ else:
def copytree(
src: StrPath,
dst: StrPath,
symlinks: bool = ...,
ignore: None | Callable[[str, list[str]], Iterable[str]] | Callable[[StrPath, list[str]], Iterable[str]] = ...,
symlinks: bool = False,
ignore: None | Callable[[str, list[str]], Iterable[str]] | Callable[[StrPath, list[str]], Iterable[str]] = None,
copy_function: Callable[[str, str], object] = ...,
ignore_dangling_symlinks: bool = ...,
ignore_dangling_symlinks: bool = False,
) -> _PathReturn: ...
_OnErrorCallback: TypeAlias = Callable[[Callable[..., Any], Any, Any], object]
@@ -124,9 +124,9 @@ def disk_usage(path: FileDescriptorOrPath) -> _ntuple_diskusage: ...
# see https://bugs.python.org/issue33140. We keep it here because it's
# in __all__.
@overload
def chown(path: StrOrBytesPath, user: str | int, group: None = ...) -> None: ...
def chown(path: StrOrBytesPath, user: str | int, group: None = None) -> None: ...
@overload
def chown(path: StrOrBytesPath, user: None = ..., *, group: str | int) -> None: ...
def chown(path: StrOrBytesPath, user: None = None, *, group: str | int) -> None: ...
@overload
def chown(path: StrOrBytesPath, user: None, group: str | int) -> None: ...
@overload
@@ -134,12 +134,12 @@ def chown(path: StrOrBytesPath, user: str | int, group: str | int) -> None: ...
if sys.version_info >= (3, 8):
@overload
def which(cmd: _StrPathT, mode: int = ..., path: StrPath | None = ...) -> str | _StrPathT | None: ...
def which(cmd: _StrPathT, mode: int = 1, path: StrPath | None = None) -> str | _StrPathT | None: ...
@overload
def which(cmd: bytes, mode: int = ..., path: StrPath | None = ...) -> bytes | None: ...
def which(cmd: bytes, mode: int = 1, path: StrPath | None = None) -> bytes | None: ...
else:
def which(cmd: _StrPathT, mode: int = ..., path: StrPath | None = ...) -> str | _StrPathT | None: ...
def which(cmd: _StrPathT, mode: int = 1, path: StrPath | None = None) -> str | _StrPathT | None: ...
def make_archive(
base_name: str,
@@ -155,11 +155,11 @@ def make_archive(
def get_archive_formats() -> list[tuple[str, str]]: ...
@overload
def register_archive_format(
name: str, function: Callable[..., object], extra_args: Sequence[tuple[str, Any] | list[Any]], description: str = ...
name: str, function: Callable[..., object], extra_args: Sequence[tuple[str, Any] | list[Any]], description: str = ""
) -> None: ...
@overload
def register_archive_format(
name: str, function: Callable[[str, str], object], extra_args: None = ..., description: str = ...
name: str, function: Callable[[str, str], object], extra_args: None = None, description: str = ""
) -> None: ...
def unregister_archive_format(name: str) -> None: ...
def unpack_archive(filename: StrPath, extract_dir: StrPath | None = None, format: str | None = None) -> None: ...
@@ -169,11 +169,11 @@ def register_unpack_format(
extensions: list[str],
function: Callable[..., object],
extra_args: Sequence[tuple[str, Any]],
description: str = ...,
description: str = "",
) -> None: ...
@overload
def register_unpack_format(
name: str, extensions: list[str], function: Callable[[str, str], object], extra_args: None = ..., description: str = ...
name: str, extensions: list[str], function: Callable[[str, str], object], extra_args: None = None, description: str = ""
) -> None: ...
def unregister_unpack_format(name: str) -> None: ...
def get_unpack_formats() -> list[tuple[str, list[str], str]]: ...