mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
Use TypedDicts for logging.config.dictConfig (#6193)
Co-authored-by: Akuli <akuviljanen17@gmail.com>
This commit is contained in:
@@ -3,12 +3,14 @@ from _typeshed import StrOrBytesPath, StrPath
|
||||
from collections.abc import Callable
|
||||
from configparser import RawConfigParser
|
||||
from threading import Thread
|
||||
from typing import IO, Any, Pattern
|
||||
from typing import IO, Any, Pattern, Sequence
|
||||
|
||||
from . import _Level
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Literal
|
||||
from typing import Literal, TypedDict
|
||||
else:
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypedDict
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
_Path = StrOrBytesPath
|
||||
@@ -19,7 +21,29 @@ DEFAULT_LOGGING_CONFIG_PORT: int
|
||||
RESET_ERROR: int # undocumented
|
||||
IDENTIFIER: Pattern[str] # undocumented
|
||||
|
||||
def dictConfig(config: dict[str, Any]) -> None: ...
|
||||
class _RootLoggerConfiguration(TypedDict, total=False):
|
||||
level: _Level
|
||||
filters: Sequence[str]
|
||||
handlers: Sequence[str]
|
||||
|
||||
class _LoggerConfiguration(_RootLoggerConfiguration, TypedDict, total=False):
|
||||
propagate: bool
|
||||
|
||||
class _OptionalDictConfigArgs(TypedDict, total=False):
|
||||
# these two can have custom factories (key: `()`) which can have extra keys
|
||||
formatters: dict[str, dict[str, Any]]
|
||||
filters: dict[str, dict[str, Any]]
|
||||
# type checkers would warn about extra keys if this was a TypedDict
|
||||
handlers: dict[str, dict[str, Any]]
|
||||
loggers: dict[str, _LoggerConfiguration]
|
||||
root: _RootLoggerConfiguration | None
|
||||
incremental: bool
|
||||
disable_existing_loggers: bool
|
||||
|
||||
class _DictConfigArgs(_OptionalDictConfigArgs, TypedDict):
|
||||
version: Literal[1]
|
||||
|
||||
def dictConfig(config: _DictConfigArgs) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
def fileConfig(
|
||||
|
||||
Reference in New Issue
Block a user