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

@@ -257,7 +257,7 @@ class Logger(Filterer):
self,
msg: object,
*args: object,
exc_info: _ExcInfoType = ...,
exc_info: _ExcInfoType = True,
stack_info: bool = ...,
extra: Mapping[str, object] | None = ...,
) -> None: ...
@@ -266,9 +266,9 @@ class Logger(Filterer):
level: int,
msg: object,
args: _ArgsType,
exc_info: _ExcInfoType | None = ...,
extra: Mapping[str, object] | None = ...,
stack_info: bool = ...,
exc_info: _ExcInfoType | None = None,
extra: Mapping[str, object] | None = None,
stack_info: bool = False,
) -> None: ... # undocumented
fatal = critical
def addHandler(self, hdlr: Handler) -> None: ...
@@ -276,7 +276,7 @@ class Logger(Filterer):
if sys.version_info >= (3, 8):
def findCaller(self, stack_info: bool = False, stacklevel: int = 1) -> tuple[str, int, str, str | None]: ...
else:
def findCaller(self, stack_info: bool = ...) -> tuple[str, int, str, str | None]: ...
def findCaller(self, stack_info: bool = False) -> tuple[str, int, str, str | None]: ...
def handle(self, record: LogRecord) -> None: ...
def makeRecord(
@@ -347,10 +347,10 @@ class Formatter:
) -> None: ...
elif sys.version_info >= (3, 8):
def __init__(
self, fmt: str | None = ..., datefmt: str | None = ..., style: _FormatStyle = ..., validate: bool = ...
self, fmt: str | None = None, datefmt: str | None = None, style: _FormatStyle = "%", validate: bool = True
) -> None: ...
else:
def __init__(self, fmt: str | None = ..., datefmt: str | None = ..., style: _FormatStyle = ...) -> None: ...
def __init__(self, fmt: str | None = None, datefmt: str | None = None, style: _FormatStyle = "%") -> None: ...
def format(self, record: LogRecord) -> str: ...
def formatTime(self, record: LogRecord, datefmt: str | None = None) -> str: ...
@@ -559,7 +559,7 @@ class LoggerAdapter(Generic[_L]):
self,
msg: object,
*args: object,
exc_info: _ExcInfoType = ...,
exc_info: _ExcInfoType = True,
stack_info: bool = ...,
extra: Mapping[str, object] | None = ...,
**kwargs: object,
@@ -693,7 +693,11 @@ else:
msg: object, *args: object, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: Mapping[str, object] | None = ...
) -> None: ...
def exception(
msg: object, *args: object, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: Mapping[str, object] | None = ...
msg: object,
*args: object,
exc_info: _ExcInfoType = True,
stack_info: bool = ...,
extra: Mapping[str, object] | None = ...,
) -> None: ...
def log(
level: int,
@@ -771,7 +775,7 @@ class StreamHandler(Handler, Generic[_StreamT]):
stream: _StreamT # undocumented
terminator: str
@overload
def __init__(self: StreamHandler[TextIO], stream: None = ...) -> None: ...
def __init__(self: StreamHandler[TextIO], stream: None = None) -> None: ...
@overload
def __init__(self: StreamHandler[_StreamT], stream: _StreamT) -> None: ...
def setStream(self, stream: _StreamT) -> _StreamT | None: ...
@@ -789,7 +793,7 @@ class FileHandler(StreamHandler[TextIOWrapper]):
self, filename: StrPath, mode: str = "a", encoding: str | None = None, delay: bool = False, errors: str | None = None
) -> None: ...
else:
def __init__(self, filename: StrPath, mode: str = ..., encoding: str | None = ..., delay: bool = ...) -> None: ...
def __init__(self, filename: StrPath, mode: str = "a", encoding: str | None = None, delay: bool = False) -> None: ...
def _open(self) -> TextIOWrapper: ... # undocumented

View File

@@ -57,8 +57,8 @@ if sys.version_info >= (3, 10):
else:
def fileConfig(
fname: StrOrBytesPath | IO[str] | RawConfigParser,
defaults: dict[str, str] | None = ...,
disable_existing_loggers: bool = ...,
defaults: dict[str, str] | None = None,
disable_existing_loggers: bool = True,
) -> None: ...
def valid_ident(s: str) -> Literal[True]: ... # undocumented

View File

@@ -25,7 +25,7 @@ class WatchedFileHandler(FileHandler):
self, filename: StrPath, mode: str = "a", encoding: str | None = None, delay: bool = False, errors: str | None = None
) -> None: ...
else:
def __init__(self, filename: StrPath, mode: str = ..., encoding: str | None = ..., delay: bool = ...) -> None: ...
def __init__(self, filename: StrPath, mode: str = "a", encoding: str | None = None, delay: bool = False) -> None: ...
def _statstream(self) -> None: ... # undocumented
def reopenIfNeeded(self) -> None: ...
@@ -38,7 +38,7 @@ class BaseRotatingHandler(FileHandler):
self, filename: StrPath, mode: str, encoding: str | None = None, delay: bool = False, errors: str | None = None
) -> None: ...
else:
def __init__(self, filename: StrPath, mode: str, encoding: str | None = ..., delay: bool = ...) -> None: ...
def __init__(self, filename: StrPath, mode: str, encoding: str | None = None, delay: bool = False) -> None: ...
def rotation_filename(self, default_name: str) -> str: ...
def rotate(self, source: str, dest: str) -> None: ...
@@ -61,11 +61,11 @@ class RotatingFileHandler(BaseRotatingHandler):
def __init__(
self,
filename: StrPath,
mode: str = ...,
maxBytes: int = ...,
backupCount: int = ...,
encoding: str | None = ...,
delay: bool = ...,
mode: str = "a",
maxBytes: int = 0,
backupCount: int = 0,
encoding: str | None = None,
delay: bool = False,
) -> None: ...
def doRollover(self) -> None: ...
@@ -98,13 +98,13 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
def __init__(
self,
filename: StrPath,
when: str = ...,
interval: int = ...,
backupCount: int = ...,
encoding: str | None = ...,
delay: bool = ...,
utc: bool = ...,
atTime: datetime.time | None = ...,
when: str = "h",
interval: int = 1,
backupCount: int = 0,
encoding: str | None = None,
delay: bool = False,
utc: bool = False,
atTime: datetime.time | None = None,
) -> None: ...
def doRollover(self) -> None: ...
@@ -210,7 +210,7 @@ class SMTPHandler(Handler):
subject: str,
credentials: tuple[str, str] | None = None,
secure: tuple[()] | tuple[str] | tuple[str, str] | None = None,
timeout: float = ...,
timeout: float = 5.0,
) -> None: ...
def getSubject(self, record: LogRecord) -> str: ...