Skip to content

Commit

Permalink
feat: strip trailing underscore from option names
Browse files Browse the repository at this point in the history
  • Loading branch information
djpohly committed Feb 6, 2024
1 parent 8951197 commit 55a3cda
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/argh/assembling.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ def infer_argspecs_from_function(
)

def _make_cli_arg_names_options(arg_name) -> Tuple[List[str], List[str]]:
# str.removesuffix() can be used here starting with Python 3.9
if arg_name.endswith("_"):
arg_name = arg_name[:-1]
cliified_arg_name = arg_name.replace("_", "-")
positionals = [cliified_arg_name]
can_have_short_opt = arg_name[0] not in conflicting_opts
Expand Down
1 change: 0 additions & 1 deletion tests/test_assembling.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,6 @@ def cmd(foo_pos, bar_pos, *args, foo_kwonly="foo_kwonly", bar_kwonly):
]


@pytest.mark.xfail()
def test_trailing_underscore_in_argument_name():
"Stripping trailing underscores from named options"

Expand Down

0 comments on commit 55a3cda

Please sign in to comment.