From dc9b3884fa12285334c2292a7fc262dc748852ea Mon Sep 17 00:00:00 2001 From: Florian Rupprecht Date: Wed, 5 Jun 2024 11:33:30 -0400 Subject: [PATCH] Slightly improve error messages --- src/styx/compiler/compile/inputs.py | 4 ++-- src/styx/model/from_boutiques.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/styx/compiler/compile/inputs.py b/src/styx/compiler/compile/inputs.py index 3a663ce..b69d688 100644 --- a/src/styx/compiler/compile/inputs.py +++ b/src/styx/compiler/compile/inputs.py @@ -73,7 +73,7 @@ def _codegen_var_to_str(arg: WithSymbol[InputArgument]) -> tuple[str, bool]: Return a boolean that indicates if the expression is an array. """ if arg.data.type.primitive == InputTypePrimitive.Flag: - assert arg.data.command_line_flag is not None, "Flag input must have a command line flag" + assert arg.data.command_line_flag is not None, f"Flag input must have a command line flag ({arg.data.name})" return enquote(arg.data.command_line_flag), False def _val() -> tuple[str, bool]: @@ -213,7 +213,7 @@ def _input_segment_to_py_arg_builder(buf: LineBuffer, segment: list[str | WithSy statement.append(enquote(token)) else: var, is_list = _codegen_var_to_str(token) - assert not is_list, "List variables are not supported in this context" + assert not is_list, f"List variables are not supported in this context ({var})" statement.append(var) buf.extend( diff --git a/src/styx/model/from_boutiques.py b/src/styx/model/from_boutiques.py index 27164ff..60df0f0 100644 --- a/src/styx/model/from_boutiques.py +++ b/src/styx/model/from_boutiques.py @@ -73,18 +73,18 @@ def _default_value_from_boutiques(bt_input: dict) -> tuple[bool, TYPE_INPUT_VALU return False, None if primitive == InputTypePrimitive.File: - assert isinstance(default_value, str) + assert isinstance(default_value, str), f"Expected string default-value, got {type(default_value)}" return True, pathlib.Path(default_value) elif primitive == InputTypePrimitive.String: - assert isinstance(default_value, str) + assert isinstance(default_value, str), f"Expected string default-value, got {type(default_value)}" elif primitive == InputTypePrimitive.Number: - assert isinstance(default_value, (int, float)) + assert isinstance(default_value, (int, float)), f"Expected number default-value, got {type(default_value)}" elif primitive == InputTypePrimitive.Integer: - assert isinstance(default_value, int) + assert isinstance(default_value, int), f"Expected integer default-value, got {type(default_value)}" elif primitive == InputTypePrimitive.Flag: - assert isinstance(default_value, bool) + assert isinstance(default_value, bool), f"Expected boolean default-value, got {type(default_value)}" elif primitive == InputTypePrimitive.SubCommand: - assert isinstance(default_value, str) + assert isinstance(default_value, str), f"Expected string default-value, got {type(default_value)}" else: raise NotImplementedError