Skip to content

Commit

Permalink
WIP: more override decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
bauen1 committed Jan 4, 2025
1 parent 2acffd3 commit e3d5059
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pyinfra_cli/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
from inspect import getframeinfo
from traceback import format_exception, format_tb, walk_tb
from typing import override
from types import TracebackType

import click
Expand Down Expand Up @@ -37,6 +38,7 @@ def __init__(self, e: Exception):
message = repr(message)
self.message = message

@override
def show(self, file=None):
name = "unknown error"

Expand Down Expand Up @@ -65,6 +67,7 @@ def show(self, file=None):


class CliError(click.ClickException):
@override
def show(self, file=None):
logger.warning(
"--> {0}: {1}".format(
Expand Down Expand Up @@ -96,6 +99,7 @@ def __init__(self, e, filename):
self.exception = e
self.filename = filename

@override
def show(self, file=None):
logger.warning(
"--> {0}:\n".format(
Expand All @@ -118,6 +122,7 @@ def __init__(self, e):
e._traceback = traceback
self.exception = e

@override
def show(self, file=None):
click.echo(
"--> {0}:\n".format(
Expand Down
4 changes: 4 additions & 0 deletions pyinfra_cli/log.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import logging

from typing import override

import click

from pyinfra import logger, state
from pyinfra.context import ctx_state


class LogHandler(logging.Handler):
@override
def emit(self, record):
try:
message = self.format(record)
Expand All @@ -25,6 +28,7 @@ class LogFormatter(logging.Formatter):
logging.CRITICAL: lambda s: click.style(s, "red", bold=True),
}

@override
def format(self, record):
message = record.msg

Expand Down

0 comments on commit e3d5059

Please sign in to comment.