mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-15 08:17:07 +08:00
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:
@@ -36,89 +36,89 @@ if sys.version_info >= (3, 10):
|
||||
# encoding and errors are added
|
||||
@overload
|
||||
def input(
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ...,
|
||||
inplace: bool = ...,
|
||||
backup: str = ...,
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None,
|
||||
inplace: bool = False,
|
||||
backup: str = "",
|
||||
*,
|
||||
mode: _TextMode = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = ...,
|
||||
encoding: str | None = ...,
|
||||
errors: str | None = ...,
|
||||
mode: _TextMode = "r",
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None,
|
||||
encoding: str | None = None,
|
||||
errors: str | None = None,
|
||||
) -> FileInput[str]: ...
|
||||
@overload
|
||||
def input(
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ...,
|
||||
inplace: bool = ...,
|
||||
backup: str = ...,
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None,
|
||||
inplace: bool = False,
|
||||
backup: str = "",
|
||||
*,
|
||||
mode: Literal["rb"],
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = ...,
|
||||
encoding: None = ...,
|
||||
errors: None = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None,
|
||||
encoding: None = None,
|
||||
errors: None = None,
|
||||
) -> FileInput[bytes]: ...
|
||||
@overload
|
||||
def input(
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ...,
|
||||
inplace: bool = ...,
|
||||
backup: str = ...,
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None,
|
||||
inplace: bool = False,
|
||||
backup: str = "",
|
||||
*,
|
||||
mode: str,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = ...,
|
||||
encoding: str | None = ...,
|
||||
errors: str | None = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None,
|
||||
encoding: str | None = None,
|
||||
errors: str | None = None,
|
||||
) -> FileInput[Any]: ...
|
||||
|
||||
elif sys.version_info >= (3, 8):
|
||||
# bufsize is dropped and mode and openhook become keyword-only
|
||||
@overload
|
||||
def input(
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ...,
|
||||
inplace: bool = ...,
|
||||
backup: str = ...,
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None,
|
||||
inplace: bool = False,
|
||||
backup: str = "",
|
||||
*,
|
||||
mode: _TextMode = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = ...,
|
||||
mode: _TextMode = "r",
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None,
|
||||
) -> FileInput[str]: ...
|
||||
@overload
|
||||
def input(
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ...,
|
||||
inplace: bool = ...,
|
||||
backup: str = ...,
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None,
|
||||
inplace: bool = False,
|
||||
backup: str = "",
|
||||
*,
|
||||
mode: Literal["rb"],
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None,
|
||||
) -> FileInput[bytes]: ...
|
||||
@overload
|
||||
def input(
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ...,
|
||||
inplace: bool = ...,
|
||||
backup: str = ...,
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None,
|
||||
inplace: bool = False,
|
||||
backup: str = "",
|
||||
*,
|
||||
mode: str,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None,
|
||||
) -> FileInput[Any]: ...
|
||||
|
||||
else:
|
||||
@overload
|
||||
def input(
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ...,
|
||||
inplace: bool = ...,
|
||||
backup: str = ...,
|
||||
bufsize: int = ...,
|
||||
mode: _TextMode = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = ...,
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None,
|
||||
inplace: bool = False,
|
||||
backup: str = "",
|
||||
bufsize: int = 0,
|
||||
mode: _TextMode = "r",
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None,
|
||||
) -> FileInput[str]: ...
|
||||
# Because mode isn't keyword-only here yet, we need two overloads each for
|
||||
# the bytes case and the fallback case.
|
||||
@overload
|
||||
def input(
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ...,
|
||||
inplace: bool = ...,
|
||||
backup: str = ...,
|
||||
bufsize: int = ...,
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None,
|
||||
inplace: bool = False,
|
||||
backup: str = "",
|
||||
bufsize: int = 0,
|
||||
*,
|
||||
mode: Literal["rb"],
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None,
|
||||
) -> FileInput[bytes]: ...
|
||||
@overload
|
||||
def input(
|
||||
@@ -127,17 +127,17 @@ else:
|
||||
backup: str,
|
||||
bufsize: int,
|
||||
mode: Literal["rb"],
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None,
|
||||
) -> FileInput[bytes]: ...
|
||||
@overload
|
||||
def input(
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ...,
|
||||
inplace: bool = ...,
|
||||
backup: str = ...,
|
||||
bufsize: int = ...,
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None,
|
||||
inplace: bool = False,
|
||||
backup: str = "",
|
||||
bufsize: int = 0,
|
||||
*,
|
||||
mode: str,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None,
|
||||
) -> FileInput[Any]: ...
|
||||
@overload
|
||||
def input(
|
||||
@@ -146,7 +146,7 @@ else:
|
||||
backup: str,
|
||||
bufsize: int,
|
||||
mode: str,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None,
|
||||
) -> FileInput[Any]: ...
|
||||
|
||||
def close() -> None: ...
|
||||
@@ -164,38 +164,38 @@ class FileInput(Iterator[AnyStr], Generic[AnyStr]):
|
||||
@overload
|
||||
def __init__(
|
||||
self: FileInput[str],
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ...,
|
||||
inplace: bool = ...,
|
||||
backup: str = ...,
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None,
|
||||
inplace: bool = False,
|
||||
backup: str = "",
|
||||
*,
|
||||
mode: _TextMode = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = ...,
|
||||
encoding: str | None = ...,
|
||||
errors: str | None = ...,
|
||||
mode: _TextMode = "r",
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None,
|
||||
encoding: str | None = None,
|
||||
errors: str | None = None,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self: FileInput[bytes],
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ...,
|
||||
inplace: bool = ...,
|
||||
backup: str = ...,
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None,
|
||||
inplace: bool = False,
|
||||
backup: str = "",
|
||||
*,
|
||||
mode: Literal["rb"],
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = ...,
|
||||
encoding: None = ...,
|
||||
errors: None = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None,
|
||||
encoding: None = None,
|
||||
errors: None = None,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self: FileInput[Any],
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ...,
|
||||
inplace: bool = ...,
|
||||
backup: str = ...,
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None,
|
||||
inplace: bool = False,
|
||||
backup: str = "",
|
||||
*,
|
||||
mode: str,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = ...,
|
||||
encoding: str | None = ...,
|
||||
errors: str | None = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None,
|
||||
encoding: str | None = None,
|
||||
errors: str | None = None,
|
||||
) -> None: ...
|
||||
|
||||
elif sys.version_info >= (3, 8):
|
||||
@@ -203,57 +203,57 @@ class FileInput(Iterator[AnyStr], Generic[AnyStr]):
|
||||
@overload
|
||||
def __init__(
|
||||
self: FileInput[str],
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ...,
|
||||
inplace: bool = ...,
|
||||
backup: str = ...,
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None,
|
||||
inplace: bool = False,
|
||||
backup: str = "",
|
||||
*,
|
||||
mode: _TextMode = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = ...,
|
||||
mode: _TextMode = "r",
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self: FileInput[bytes],
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ...,
|
||||
inplace: bool = ...,
|
||||
backup: str = ...,
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None,
|
||||
inplace: bool = False,
|
||||
backup: str = "",
|
||||
*,
|
||||
mode: Literal["rb"],
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self: FileInput[Any],
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ...,
|
||||
inplace: bool = ...,
|
||||
backup: str = ...,
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None,
|
||||
inplace: bool = False,
|
||||
backup: str = "",
|
||||
*,
|
||||
mode: str,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None,
|
||||
) -> None: ...
|
||||
|
||||
else:
|
||||
@overload
|
||||
def __init__(
|
||||
self: FileInput[str],
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ...,
|
||||
inplace: bool = ...,
|
||||
backup: str = ...,
|
||||
bufsize: int = ...,
|
||||
mode: _TextMode = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = ...,
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None,
|
||||
inplace: bool = False,
|
||||
backup: str = "",
|
||||
bufsize: int = 0,
|
||||
mode: _TextMode = "r",
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[str]] | None = None,
|
||||
) -> None: ...
|
||||
# Because mode isn't keyword-only here yet, we need two overloads each for
|
||||
# the bytes case and the fallback case.
|
||||
@overload
|
||||
def __init__(
|
||||
self: FileInput[bytes],
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ...,
|
||||
inplace: bool = ...,
|
||||
backup: str = ...,
|
||||
bufsize: int = ...,
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None,
|
||||
inplace: bool = False,
|
||||
backup: str = "",
|
||||
bufsize: int = 0,
|
||||
*,
|
||||
mode: Literal["rb"],
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
@@ -263,18 +263,18 @@ class FileInput(Iterator[AnyStr], Generic[AnyStr]):
|
||||
backup: str,
|
||||
bufsize: int,
|
||||
mode: Literal["rb"],
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[bytes]] | None = None,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self: FileInput[Any],
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = ...,
|
||||
inplace: bool = ...,
|
||||
backup: str = ...,
|
||||
bufsize: int = ...,
|
||||
files: StrOrBytesPath | Iterable[StrOrBytesPath] | None = None,
|
||||
inplace: bool = False,
|
||||
backup: str = "",
|
||||
bufsize: int = 0,
|
||||
*,
|
||||
mode: str,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
@@ -284,7 +284,7 @@ class FileInput(Iterator[AnyStr], Generic[AnyStr]):
|
||||
backup: str,
|
||||
bufsize: int,
|
||||
mode: str,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = ...,
|
||||
openhook: Callable[[StrOrBytesPath, str], _HasReadlineAndFileno[Any]] | None = None,
|
||||
) -> None: ...
|
||||
|
||||
def __del__(self) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user