Merge pull request #4564 from beetbox/flake8-config

Fix some CI breakage due to backwards-incompatible flake8 changes
This commit is contained in:
Adrian Sampson 2022-11-28 08:46:28 -08:00 committed by GitHub
commit 3077a3a32d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 22 deletions

View file

@ -22,9 +22,9 @@ that when getLogger(name) instantiates a logger that logger uses
from copy import copy
from logging import * # noqa
import subprocess
import threading
import logging
def logsafe(val):
@ -66,7 +66,7 @@ def logsafe(val):
return val
class StrFormatLogger(Logger):
class StrFormatLogger(logging.Logger):
"""A version of `Logger` that uses `str.format`-style formatting
instead of %-style formatting.
"""
@ -88,13 +88,13 @@ class StrFormatLogger(Logger):
return super()._log(level, m, (), exc_info, extra)
class ThreadLocalLevelLogger(Logger):
class ThreadLocalLevelLogger(logging.Logger):
"""A version of `Logger` whose level is thread-local instead of shared.
"""
def __init__(self, name, level=NOTSET):
def __init__(self, name, level=logging.NOTSET):
self._thread_level = threading.local()
self.default_level = NOTSET
self.default_level = logging.NOTSET
super().__init__(name, level)
@property
@ -121,12 +121,16 @@ class BeetsLogger(ThreadLocalLevelLogger, StrFormatLogger):
pass
my_manager = copy(Logger.manager)
my_manager = copy(logging.Logger.manager)
my_manager.loggerClass = BeetsLogger
# Act like the stdlib logging module by re-exporting its namespace.
from logging import * # noqa
# Override the `getLogger` to use our machinery.
def getLogger(name=None): # noqa
if name:
return my_manager.getLogger(name)
else:
return Logger.root
return logging.Logger.root

View file

@ -5,21 +5,27 @@ docstring-convention = google
# errors we ignore; see https://www.flake8rules.com/ for more info
ignore =
# pycodestyle errors
E121, # continuation line under-indented for hanging indent
E123, # closing bracket does not match indentation of opening bracket's line
E126, # continuation line over-indented for hangin indent
E241, # multiple spaces after non-arithmetic operators (for vertical alignment)
E305, # expected 2 blank lines after end of function or class
E731, # do not assign a lamba expression, use a def
E741, # do not use variables name 'I', 'O', or 'l'
# pycodestyle warnings
W503, # line break occurred before a binary operator
W504, # line break occurred after a binary operator
# pyflakes errors
F405, # name be undefined, or defined from star imports: module
# mccabe error
C901, # function is too complex
N818, # Exception subclasses should be named with an Error suffix
# continuation line under-indented for hanging indent
E121,
# closing bracket does not match indentation of opening bracket's line
E123,
# continuation line over-indented for hanging indent
E126,
# multiple spaces after non-arithmetic operators (for vertical alignment)
E241,
# expected 2 blank lines after end of function or class
E305,
# do not assign a lambda expression, use a def
E731,
# do not use variables name 'I', 'O', or 'l'
E741,
# pycodestyle warnings: line breaks around binary operators
W503,
W504,
# mccabe errors: function is too complex
C901,
# Exception subclasses should be named with an Error suffix
N818,
per-file-ignores =
./beet:D
./docs/conf.py:D