diff --git a/colorlog/formatter.py b/colorlog/formatter.py index 6d845ee..f011ca2 100644 --- a/colorlog/formatter.py +++ b/colorlog/formatter.py @@ -18,6 +18,10 @@ EscapeCodes = typing.Mapping[str, str] LogColors = typing.Mapping[str, str] SecondaryLogColors = typing.Mapping[str, LogColors] +if sys.version_info >= (3, 8): + _FormatStyle = typing.Literal["%", "{", "$"] +else: + _FormatStyle = str # The default colors to use for the debug levels default_log_colors = { @@ -60,7 +64,7 @@ def __init__( self, fmt: typing.Optional[str] = None, datefmt: typing.Optional[str] = None, - style: str = "%", + style: _FormatStyle = "%", log_colors: typing.Optional[LogColors] = None, reset: bool = True, secondary_log_colors: typing.Optional[SecondaryLogColors] = None, @@ -89,7 +93,7 @@ def __init__( - reset (bool): Implicitly append a color reset to all records unless False. - style ('%' or '{' or '$'): - The format style to use. (*No meaning prior to Python 3.2.*) + The format style to use. - secondary_log_colors (dict): Map secondary ``log_color`` attributes. (*New in version 2.6.*) - validate (bool) diff --git a/colorlog/wrappers.py b/colorlog/wrappers.py index 7434ef5..20e3042 100644 --- a/colorlog/wrappers.py +++ b/colorlog/wrappers.py @@ -43,7 +43,7 @@ def basicConfig( - style: str = "%", + style: colorlog.formatter._FormatStyle = "%", log_colors: typing.Optional[colorlog.formatter.LogColors] = None, reset: bool = True, secondary_log_colors: typing.Optional[colorlog.formatter.SecondaryLogColors] = None,