Skip to content

Commit

Permalink
Upgrade Python syntax with pyupgrade --py36-plus
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored and borntyping committed Jun 14, 2021
1 parent fe481ce commit 1350cec
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
2 changes: 0 additions & 2 deletions colorlog/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""A logging formatter for colored output."""

from __future__ import absolute_import

import sys
import warnings

Expand Down
10 changes: 4 additions & 6 deletions colorlog/colorlog.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""The ColoredFormatter class."""

from __future__ import absolute_import

import logging
import os
import sys
Expand Down Expand Up @@ -39,7 +37,7 @@
}


class ColoredRecord(object):
class ColoredRecord:
"""
Wraps a LogRecord, adding escape codes to the internal dict.
Expand Down Expand Up @@ -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 = (
Expand All @@ -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

Expand Down
2 changes: 0 additions & 2 deletions colorlog/logging.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Wrappers around the logging module."""

from __future__ import absolute_import

import functools
import logging
import typing
Expand Down
4 changes: 1 addition & 3 deletions colorlog/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Fixtures that can be used in other tests."""

from __future__ import print_function

import inspect
import logging
import sys
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 1350cec

Please sign in to comment.