move TypeVar T to utils module

This commit is contained in:
sebthom
2022-03-12 19:30:11 +01:00
parent 2597b902be
commit c6fd4f25ae
2 changed files with 6 additions and 7 deletions

View File

@@ -6,7 +6,7 @@ import copy, decimal, json, logging, os, re, secrets, sys, traceback, time
from importlib.resources import read_text as get_resource_as_string
from collections.abc import Callable, Iterable
from types import ModuleType
from typing import Any, Final
from typing import Any, Final, TypeVar
import coloredlogs, inflect
from ruamel.yaml import YAML
@@ -14,6 +14,8 @@ from ruamel.yaml import YAML
LOG_ROOT:Final[logging.Logger] = logging.getLogger()
LOG:Final[logging.Logger] = logging.getLogger("kleinanzeigen_bot.utils")
T:Final[TypeVar] = TypeVar('T')
def abspath(relative_path:str, relative_to:str = None):
"""
@@ -123,8 +125,7 @@ def configure_console_logging() -> None:
def on_exception(ex_type, ex_value, ex_traceback) -> None:
if issubclass(ex_type, KeyboardInterrupt):
sys.__excepthook__(ex_type, ex_value, ex_traceback)
return
if LOG.isEnabledFor(logging.DEBUG) or isinstance(ex_value, (AttributeError, ImportError, NameError, TypeError)):
elif LOG.isEnabledFor(logging.DEBUG) or isinstance(ex_value, (AttributeError, ImportError, NameError, TypeError)):
LOG.error("".join(traceback.format_exception(ex_type, ex_value, ex_traceback)))
elif isinstance(ex_value, AssertionError):
LOG.error(ex_value)