Skip to content

Commit

Permalink
fix: remove underscores when matching input args
Browse files Browse the repository at this point in the history
  • Loading branch information
djpohly committed Feb 6, 2024
1 parent 9c709b8 commit f3ff611
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/argh/dispatching.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,11 @@ def _flat_key(key):
kwonly_names = [p.name for p in func_params if p.kind == p.KEYWORD_ONLY]
varargs_names = [p.name for p in func_params if p.kind == p.VAR_POSITIONAL]
positional_values = [values_by_arg_name[name] for name in positional_names]
values_by_name = dict((k, values_by_arg_name[k]) for k in kwonly_names)
# str.removesuffix() can be used from Python 3.9 onward
values_by_name = dict(
(k, values_by_arg_name[k[:-1] if k.endswith("_") else k])
for k in kwonly_names
)

# *args
if varargs_names:
Expand Down
1 change: 0 additions & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,6 @@ def cmd(a_b):
assert run(parser, "hello").out == "hello\n"


@pytest.mark.xfail
def test_trailing_underscore_keys():
"""One trailing underscore is ignored in function args."""

Expand Down

0 comments on commit f3ff611

Please sign in to comment.