Skip to content

Commit

Permalink
fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
skatsaounis committed Nov 27, 2024
1 parent 6cc6749 commit 18c9b07
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions anvil-python/anvil/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@
class EpilogFormatterMixin:
"""Mixin class for formatting epilogs with examples."""

def __init__(self, epilog: str | None = None) -> None:
self.epilog = epilog

def format_epilog(
self, ctx: click.Context, formatter: click.HelpFormatter
) -> None:
"""Writes the epilog into the formatter if it exists."""
# We need to overwrite the default behaviour because otherwise
# We need to overwrite the default behavior because otherwise
# the whole Example block would be indented.
if self.epilog:
epilog = inspect.cleandoc(self.epilog)
Expand Down Expand Up @@ -66,7 +69,7 @@ def __call__(self, *args, **kwargs): # type: ignore[no-untyped-def]
"An unexpected error has occurred."
" Please run 'maas-anvil inspect' to generate an inspection report."
)
LOG.warn(message)
LOG.warning(message)
LOG.error("Error: %s", e)
sys.exit(1)

Expand Down Expand Up @@ -106,7 +109,7 @@ def format_commands(

# First pass: collect all commands and find the longest one
# so we can later apply appropriate padding so table columns
# are alligned across tables
# are aligned across tables
all_commands = []
for _, filters in commandGroups:
for cmd_name, filter_fn in filters:
Expand All @@ -115,7 +118,7 @@ def format_commands(
continue

if filter_fn is None:
all_commands.append(cmd.name)
all_commands.append(f"{cmd.name}")
elif isinstance(
cmd, click.Group
): # Type check for subcommands
Expand All @@ -127,7 +130,7 @@ def format_commands(
max(len(cmd) for cmd in all_commands) if all_commands else 0
)

# Click by default has no concept of groups so we need to generate them ourselfs
# Click by default has no concept of groups so we need to generate them ourselves
with formatter.section("Commands"):
first = True

Expand All @@ -150,7 +153,7 @@ def format_commands(
if filter_fn is None:
group_commands.append(
(
cmd.name.ljust(max_length),
f"{cmd.name}".ljust(max_length),
cmd.get_short_help_str(75),
)
)
Expand Down

0 comments on commit 18c9b07

Please sign in to comment.