Add several version-dependent default values to parameters in the stdlib (#9631)

This commit is contained in:
Alex Waygood
2023-01-31 01:21:39 +00:00
committed by GitHub
parent 81463b9995
commit a6919227be
5 changed files with 28 additions and 8 deletions

View File

@@ -849,8 +849,10 @@ class memoryview(Sequence[int]):
def __setitem__(self, __s: slice, __o: ReadableBuffer) -> None: ...
@overload
def __setitem__(self, __i: SupportsIndex, __o: SupportsIndex) -> None: ...
if sys.version_info >= (3, 8):
def tobytes(self, order: Literal["C", "F", "A"] | None = ...) -> bytes: ...
if sys.version_info >= (3, 10):
def tobytes(self, order: Literal["C", "F", "A"] | None = "C") -> bytes: ...
elif sys.version_info >= (3, 8):
def tobytes(self, order: Literal["C", "F", "A"] | None = None) -> bytes: ...
else:
def tobytes(self) -> bytes: ...

View File

@@ -1,3 +1,4 @@
import sys
import types
from _codecs import *
from _typeshed import ReadableBuffer, Self
@@ -127,9 +128,17 @@ def getincrementalencoder(encoding: str) -> _IncrementalEncoder: ...
def getincrementaldecoder(encoding: str) -> _IncrementalDecoder: ...
def getreader(encoding: str) -> _StreamReader: ...
def getwriter(encoding: str) -> _StreamWriter: ...
def open(
filename: str, mode: str = "r", encoding: str | None = None, errors: str = "strict", buffering: int = ...
) -> StreamReaderWriter: ...
if sys.version_info >= (3, 8):
def open(
filename: str, mode: str = "r", encoding: str | None = None, errors: str = "strict", buffering: int = -1
) -> StreamReaderWriter: ...
else:
def open(
filename: str, mode: str = "r", encoding: str | None = None, errors: str = "strict", buffering: int = 1
) -> StreamReaderWriter: ...
def EncodedFile(file: _Stream, data_encoding: str, file_encoding: str | None = None, errors: str = "strict") -> StreamRecoder: ...
def iterencode(iterator: Iterable[str], encoding: str, errors: str = "strict") -> Generator[bytes, None, None]: ...
def iterdecode(iterator: Iterable[bytes], encoding: str, errors: str = "strict") -> Generator[str, None, None]: ...

View File

@@ -7,7 +7,7 @@ ERROR: int
FATAL: int
class Log:
def __init__(self, threshold: int = ...) -> None: ...
def __init__(self, threshold: int = 3) -> None: ...
def log(self, level: int, msg: str, *args: Any) -> None: ...
def debug(self, msg: str, *args: Any) -> None: ...
def info(self, msg: str, *args: Any) -> None: ...

View File

@@ -47,7 +47,12 @@ class ExecError(OSError): ...
class ReadError(OSError): ...
class RegistryError(Exception): ...
def copyfileobj(fsrc: SupportsRead[AnyStr], fdst: SupportsWrite[AnyStr], length: int = ...) -> None: ...
if sys.version_info >= (3, 8):
def copyfileobj(fsrc: SupportsRead[AnyStr], fdst: SupportsWrite[AnyStr], length: int = 0) -> None: ...
else:
def copyfileobj(fsrc: SupportsRead[AnyStr], fdst: SupportsWrite[AnyStr], length: int = 16384) -> 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: ...

View File

@@ -354,7 +354,11 @@ class TarInfo:
@linkpath.setter
def linkpath(self, linkname: str) -> None: ...
def get_info(self) -> Mapping[str, str | int | bytes | Mapping[str, str]]: ...
def tobuf(self, format: int | None = ..., encoding: str | None = "utf-8", errors: str = "surrogateescape") -> bytes: ...
if sys.version_info >= (3, 8):
def tobuf(self, format: int | None = 2, encoding: str | None = "utf-8", errors: str = "surrogateescape") -> bytes: ...
else:
def tobuf(self, format: int | None = 1, encoding: str | None = "utf-8", errors: str = "surrogateescape") -> bytes: ...
def create_ustar_header(
self, info: Mapping[str, str | int | bytes | Mapping[str, str]], encoding: str, errors: str
) -> bytes: ...