From 1350cec84179b7735aaab69023883d4ead828eb1 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Mon, 14 Jun 2021 15:45:11 +0300 Subject: [PATCH] Upgrade Python syntax with pyupgrade --py36-plus --- colorlog/__init__.py | 2 -- colorlog/colorlog.py | 10 ++++------ colorlog/logging.py | 2 -- colorlog/tests/conftest.py | 4 +--- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/colorlog/__init__.py b/colorlog/__init__.py index 98aef78..edd5f62 100644 --- a/colorlog/__init__.py +++ b/colorlog/__init__.py @@ -1,7 +1,5 @@ """A logging formatter for colored output.""" -from __future__ import absolute_import - import sys import warnings diff --git a/colorlog/colorlog.py b/colorlog/colorlog.py index d3a00d7..c394850 100644 --- a/colorlog/colorlog.py +++ b/colorlog/colorlog.py @@ -1,7 +1,5 @@ """The ColoredFormatter class.""" -from __future__ import absolute_import - import logging import os import sys @@ -39,7 +37,7 @@ } -class ColoredRecord(object): +class ColoredRecord: """ Wraps a LogRecord, adding escape codes to the internal dict. @@ -104,9 +102,9 @@ def __init__( fmt = default_formats[style] if fmt is None else fmt if sys.version_info >= (3, 8): - super(ColoredFormatter, self).__init__(fmt, datefmt, style, validate) + super().__init__(fmt, datefmt, style, validate) else: - super(ColoredFormatter, self).__init__(fmt, datefmt, style) + super().__init__(fmt, datefmt, style) self.log_colors = log_colors if log_colors is not None else default_log_colors self.secondary_log_colors = ( @@ -120,7 +118,7 @@ def formatMessage(self, record: logging.LogRecord) -> str: """Format a message from a record object.""" escapes = self._escape_code_map(record.levelname) wrapper = ColoredRecord(record, escapes) - message = super(ColoredFormatter, self).formatMessage(wrapper) # type: ignore + message = super().formatMessage(wrapper) # type: ignore message = self._append_reset(message, escapes) return message diff --git a/colorlog/logging.py b/colorlog/logging.py index cb1d7ce..3299b12 100644 --- a/colorlog/logging.py +++ b/colorlog/logging.py @@ -1,7 +1,5 @@ """Wrappers around the logging module.""" -from __future__ import absolute_import - import functools import logging import typing diff --git a/colorlog/tests/conftest.py b/colorlog/tests/conftest.py index cbd91ac..65fd6d4 100644 --- a/colorlog/tests/conftest.py +++ b/colorlog/tests/conftest.py @@ -1,7 +1,5 @@ """Fixtures that can be used in other tests.""" -from __future__ import print_function - import inspect import logging import sys @@ -50,7 +48,7 @@ def function(logger, validator=None): if validator is not None: for line in lines: valid = validator(line.strip()) - assert valid, "{!r} did not validate".format(line.strip()) + assert valid, f"{line.strip()!r} did not validate" return lines