Skip to content

Commit

Permalink
Slightly improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nx10 committed Jun 5, 2024
1 parent cd8c335 commit dc9b388
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/styx/compiler/compile/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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(
Expand Down
12 changes: 6 additions & 6 deletions src/styx/model/from_boutiques.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit dc9b388

Please sign in to comment.