diff --git a/secureli/abstractions/echo.py b/secureli/abstractions/echo.py index 9308073b..4140b0b6 100644 --- a/secureli/abstractions/echo.py +++ b/secureli/abstractions/echo.py @@ -27,15 +27,26 @@ class EchoAbstraction(ABC): it harms our ability to refactor!) """ - def __init__(self, level: str): # TODO should we be using the EchoLevel enum in settings.py? + def __init__(self, level: str): self.print_enabled = level != EchoLevel.off self.debug_enabled = level == EchoLevel.debug self.info_enabled = level in [EchoLevel.debug, EchoLevel.info] self.warn_enabled = level in [EchoLevel.debug, EchoLevel.info, EchoLevel.warn] - self.error_enabled = level in [EchoLevel.debug, EchoLevel.info, EchoLevel.warn, EchoLevel.error] + self.error_enabled = level in [ + EchoLevel.debug, + EchoLevel.info, + EchoLevel.warn, + EchoLevel.error, + ] @abstractmethod - def _echo(self, message: str, color: Optional[Color] = None, bold: bool = False, fd: IO = sys.stdout): + def _echo( + self, + message: str, + color: Optional[Color] = None, + bold: bool = False, + fd: IO = sys.stdout, + ): """ Print the provided message to the terminal with the associated color and weight :param message: The message to print @@ -110,7 +121,13 @@ class TyperEcho(EchoAbstraction): def __init__(self, level: str) -> None: super().__init__(level) - def _echo(self, message: str, color: Optional[Color] = None, bold: bool = False, fd: IO = sys.stdout) -> None: + def _echo( + self, + message: str, + color: Optional[Color] = None, + bold: bool = False, + fd: IO = sys.stdout, + ) -> None: fg = color.value if color else None message = typer.style(f"[seCureLI] {message}", fg=fg, bold=bold) typer.echo(message, file=fd) diff --git a/secureli/utilities/logging.py b/secureli/utilities/logging.py index d1164f3c..49642cae 100644 --- a/secureli/utilities/logging.py +++ b/secureli/utilities/logging.py @@ -1,5 +1,6 @@ from enum import Enum + class EchoLevel(str, Enum): debug = "DEBUG" info = "INFO" diff --git a/tests/abstractions/test_typer_echo.py b/tests/abstractions/test_typer_echo.py index f2e09853..67320f97 100644 --- a/tests/abstractions/test_typer_echo.py +++ b/tests/abstractions/test_typer_echo.py @@ -4,6 +4,7 @@ import pytest + @pytest.fixture() def mock_echo_text() -> str: return "Hello, There"