diff --git a/pyglossary/core.py b/pyglossary/core.py index 02bcced54..a7cc2b325 100644 --- a/pyglossary/core.py +++ b/pyglossary/core.py @@ -11,13 +11,9 @@ isfile, join, ) -from typing import TYPE_CHECKING from . import logger -from .logger import TRACE - -if TYPE_CHECKING: - import logging +from .logger import TRACE, trace def exc_note(e: Exception, note: str) -> Exception: @@ -60,18 +56,9 @@ def exc_note(e: Exception, note: str) -> Exception: homePage = "https://github.com/ilius/pyglossary" - noColor = False -def trace(log: logging.Logger, msg: str) -> None: - func = getattr(log, "trace", None) - if func is None: - log.error(f"Logger {log} has no 'trace' method") - return - func(msg) - - def checkCreateConfDir() -> None: if not isdir(confDir): if exists(confDir): # file, or anything other than directory diff --git a/pyglossary/logger.py b/pyglossary/logger.py index 0a705597c..91b78a8e5 100644 --- a/pyglossary/logger.py +++ b/pyglossary/logger.py @@ -31,6 +31,14 @@ logging.addLevelName(TRACE, "TRACE") +def trace(log: logging.Logger, msg: str) -> None: + func = getattr(log, "trace", None) + if func is None: + log.error(f"Logger {log} has no 'trace' method") + return + func(msg) + + class _Formatter(logging.Formatter): def __init__(self, *args, **kwargs) -> None: # noqa: ANN002, ANN003 logging.Formatter.__init__(self, *args, **kwargs) diff --git a/pyglossary/plugins/appledict_bin/key_data.py b/pyglossary/plugins/appledict_bin/key_data.py index a48e1ce0c..7f1a359cc 100644 --- a/pyglossary/plugins/appledict_bin/key_data.py +++ b/pyglossary/plugins/appledict_bin/key_data.py @@ -17,7 +17,7 @@ import typing if typing.TYPE_CHECKING: - from collections.abc import Sequence + from collections.abc import Sequence __all__ = ["KeyData", "RawKeyData"]