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

Allow exception visibility in CLI #2735

Merged
merged 1 commit into from
Mar 13, 2024
Merged

Allow exception visibility in CLI #2735

merged 1 commit into from
Mar 13, 2024

Conversation

Ulincsys
Copy link
Contributor

Description
This change makes the CLI pass-through all exceptions when they occur while loading a module.

Previously, import exceptions were silenced during import of a CLI command module. Although most exceptions would have been displayed, by catching ModuleNotFoundError, any import errors in sub-modules would be silenced during Click imports.

The fix is to check first if the module exists using a file check, and if it does not, return None to indicate as such.

Signed commits

  • Yes, I signed my commits.

Signed-off-by: Ulincsys <ulincsys@gmail.com>
@@ -7,6 +7,8 @@
import click
import importlib
import traceback

from pathlib import Path
# import augur.application

CONTEXT_SETTINGS = dict(auto_envvar_prefix='AUGUR')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
R1735: Consider using '{"auto_envvar_prefix": 'AUGUR'}' instead of a call to 'dict'. (use-dict-literal)

@@ -24,11 +26,16 @@ def list_commands(self, ctx):
return rv

def get_command(self, ctx, name):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0237: Parameter 'cmd_name' has been renamed to 'name' in overriding 'AugurMultiCommand.get_command' method (arguments-renamed)

@@ -24,11 +26,16 @@ def list_commands(self, ctx):
return rv

def get_command(self, ctx, name):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)

IsaacMilarky
IsaacMilarky previously approved these changes Mar 13, 2024
Copy link
Contributor

@IsaacMilarky IsaacMilarky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM this is needed

sgoggins
sgoggins previously approved these changes Mar 13, 2024
Copy link
Member

@sgoggins sgoggins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@sgoggins sgoggins changed the base branch from main to dev March 13, 2024 18:15
@sgoggins sgoggins dismissed stale reviews from IsaacMilarky and themself March 13, 2024 18:15

The base branch was changed.

@sgoggins sgoggins self-requested a review March 13, 2024 18:15
@sgoggins sgoggins merged commit 48e93be into dev Mar 13, 2024
9 checks passed
@Ulincsys Ulincsys deleted the cli-raise-exception branch March 13, 2024 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants