Skip to content

Commit d233f4f

Browse files
fix: better error message for missing plugin args
1 parent c7c02a3 commit d233f4f

File tree

1 file changed

+10
-2
lines changed
  • snakemake_interface_common/plugin_registry

1 file changed

+10
-2
lines changed

snakemake_interface_common/plugin_registry/plugin.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,23 @@ def register_cli_args(self, argparser):
155155
settings.add_argument(*args, **kwargs)
156156

157157
def validate_settings(self, settings):
158+
def get_description(thefield):
159+
envvar = (
160+
f" (or environment variable {self.get_envvar(thefield.name)})"
161+
if thefield.metadata.get("env_var", None)
162+
else ""
163+
)
164+
return f"{self.get_cli_arg(thefield.name)}{envvar}"
165+
158166
# rewrite for settings
159167
missing = [
160-
thefield.name
168+
thefield
161169
for thefield in fields(settings)
162170
if thefield.metadata.get("required")
163171
and getattr(settings, thefield.name) is None
164172
]
165173
if missing:
166-
cli_args = [self.get_cli_arg(name) for name in missing]
174+
cli_args = [get_description(thefield) for thefield in missing]
167175
raise WorkflowError(
168176
f"The following required arguments are missing for "
169177
f"plugin {self.name}: {', '.join(cli_args)}."

0 commit comments

Comments
 (0)