From 4db654226913e5efa3a5d2a6b7952cd533aaaa07 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Mon, 10 May 2021 15:22:56 +0100 Subject: [PATCH 1/2] EDMCLogging: No fn.__qualname__ ? Just use `name`. --- EDMCLogging.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/EDMCLogging.py b/EDMCLogging.py index 3376cbbe..6633064e 100644 --- a/EDMCLogging.py +++ b/EDMCLogging.py @@ -363,6 +363,9 @@ class EDMCContextFilter(logging.Filter): else: caller_qualname = f"" + elif not hasattr(fn, '__qualname__'): + caller_qualname = name + elif hasattr(fn, '__qualname__') and fn.__qualname__: caller_qualname = fn.__qualname__ From bf54af721180fe5c5abd85f463cd091970f71712 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Mon, 10 May 2021 15:34:49 +0100 Subject: [PATCH 2/2] Lint new EDMCLogging test --- tests/EDMCLogging.py/test_logging_classvar.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/EDMCLogging.py/test_logging_classvar.py b/tests/EDMCLogging.py/test_logging_classvar.py index 9cd68b64..3bedb0f5 100644 --- a/tests/EDMCLogging.py/test_logging_classvar.py +++ b/tests/EDMCLogging.py/test_logging_classvar.py @@ -1,3 +1,4 @@ +"""Test that logging works correctly from a class-definition caller.""" import sys sys.path += "../" # Dont ask me why for this one it breaks, it just does. @@ -15,17 +16,17 @@ class ClassVarLogger: """Test class with logger attached.""" @classmethod - def set_logger(cls, logger): + def set_logger(cls, logger) -> None: """Set the passed logger onto the _class_.""" - ClassVarLogger.logger = logger + ClassVarLogger.logger = logger # type: ignore -def log_stuff(msg: str): - """Wrapper logger func.""" +def log_stuff(msg: str) -> None: + """Wrap logging in another function.""" ClassVarLogger.logger.debug(msg) # type: ignore # its there -def test_class_logger(caplog: 'LogCaptureFixture'): +def test_class_logger(caplog: 'LogCaptureFixture') -> None: """ Test that logging from a class variable doesn't explode.