Skip to content

Commit

Permalink
feat: more informative error message
Browse files Browse the repository at this point in the history
  • Loading branch information
neithere committed Oct 23, 2023
1 parent 54f348b commit 544b04f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/argh/assembling.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,10 @@ def _merge_inferred_and_declared_args(
kind_declared = kinds[decl_positional]
raise AssemblingError(
f'argument "{func_arg_name}" declared as {kind_inferred} '
f"(in function signature) and {kind_declared} (via decorator)"
f"(in function signature) and {kind_declared} (via decorator). "
"If you've just migrated from Argh v.0.29, please check "
"the new default NameMappingPolicy. Perhaps you need "
"to replace `func(x=1)` with `func(*, x=1)`?"
)

# merge explicit argument declaration into the inferred one
Expand Down
4 changes: 3 additions & 1 deletion tests/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ def func(foo_bar):
parser.set_default_command(func)
msg = (
'func: argument "foo_bar" declared as positional (in function '
"signature) and optional (via decorator)"
"signature) and optional (via decorator). If you've just migrated "
"from Argh v.0.29, please check the new default NameMappingPolicy. "
"Perhaps you need to replace `func(x=1)` with `func(*, x=1)`?"
)
assert excinfo.exconly().endswith(msg)

Expand Down

0 comments on commit 544b04f

Please sign in to comment.