diff --git a/src/argh/assembling.py b/src/argh/assembling.py index 7a690ea..cad4319 100644 --- a/src/argh/assembling.py +++ b/src/argh/assembling.py @@ -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 diff --git a/tests/test_assembling.py b/tests/test_assembling.py index 6243513..f1dfd35 100644 --- a/tests/test_assembling.py +++ b/tests/test_assembling.py @@ -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"