Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove CatchGroup class #610

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions tdp/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,6 @@
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])


class CatchGroup(click.Group):
"""Catch exceptions and print them to stderr."""

def __call__(self, *args, **kwargs):
try:
return self.main(*args, **kwargs)

except Exception as e:
click.echo(f"Error: {e}", err=True)


def load_env(ctx: click.Context, param: click.Parameter, value: Path) -> Optional[Path]:
"""Click callback to load the environment file."""
if value.exists():
Expand All @@ -44,7 +33,7 @@ def load_env(ctx: click.Context, param: click.Parameter, value: Path) -> Optiona
logging.warning(f"Environment file {value} does not exist.")


@click.group("tdp", context_settings=CONTEXT_SETTINGS, cls=CatchGroup)
@click.group("tdp", context_settings=CONTEXT_SETTINGS)
@click.option(
"--env",
default=".env",
Expand Down
Loading