Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lint fixes
Browse files Browse the repository at this point in the history
tdurk93 committed Nov 22, 2023
1 parent c6f7ded commit 077cfc0
Showing 3 changed files with 23 additions and 4 deletions.
25 changes: 21 additions & 4 deletions secureli/abstractions/echo.py
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions secureli/utilities/logging.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from enum import Enum


class EchoLevel(str, Enum):
debug = "DEBUG"
info = "INFO"
1 change: 1 addition & 0 deletions tests/abstractions/test_typer_echo.py
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

import pytest


@pytest.fixture()
def mock_echo_text() -> str:
return "Hello, There"

0 comments on commit 077cfc0

Please sign in to comment.