Skip to content

Commit

Permalink
Merge pull request #209 from neithere/release/v0.30.3
Browse files Browse the repository at this point in the history
Release v0.30.3
  • Loading branch information
neithere authored Oct 30, 2023
2 parents d764de9 + 6992b31 commit 17d3365
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 12 deletions.
8 changes: 8 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
Changelog
~~~~~~~~~

Version 0.30.3 (2023-10-30)
---------------------------

Bugs fixed:

- Regression: a positional argument with an underscore used in `@arg` decorator
would cause Argh fail on the assembling stage. (#208)

Version 0.30.2 (2023-10-24)
---------------------------

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi"

[project]
name = "argh"
version = "0.30.2"
version = "0.30.3"
description = "An unobtrusive argparse wrapper with natural syntax"
readme = "README.rst"
requires-python = ">=3.8"
Expand Down
3 changes: 2 additions & 1 deletion src/argh/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ def wrapper(func: Callable) -> Callable:
raise CliArgToFuncArgGuessingError("at least one CLI arg must be defined")

func_arg_name = naive_guess_func_arg_name(args)
cli_arg_names = [name.replace("_", "-") for name in args]
completer = kwargs.pop("completer", None)
spec = ParserAddArgumentSpec.make_from_kwargs(
func_arg_name=func_arg_name,
cli_arg_names=args,
cli_arg_names=cli_arg_names,
parser_add_argument_kwargs=kwargs,
)
if completer:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ def func():
assert attrs == [
ParserAddArgumentSpec(
func_arg_name="foo",
cli_arg_names=("foo",),
cli_arg_names=["foo"],
nargs="+",
other_add_parser_kwargs={
"help": "my help",
},
),
ParserAddArgumentSpec(
func_arg_name="bar",
cli_arg_names=("--bar",),
cli_arg_names=["--bar"],
default_value=1,
),
]
Expand Down
23 changes: 15 additions & 8 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,14 +735,21 @@ def remind(
parser = DebugArghParser()
parser.set_default_command(remind)

assert "Basil" in parser.format_help()
assert "Moose" in parser.format_help()
assert "creatures" in parser.format_help()

# explicit help message is not obscured by the implicit one...
assert "remarkable animal" in parser.format_help()
# ...but is still present
assert "it can speak" in parser.format_help()
help_normalised = re.sub(r"\s+", " ", parser.format_help())

assert "name 'Basil'" in help_normalised
assert "-t TASK, --task TASK 'hang the Moose'" in help_normalised
assert (
"-r REASON, --reason REASON 'there are creatures living in it'"
in help_normalised
)

# explicit help message is not obscured by the implicit one
# but is still present
assert (
"-n NOTE, --note NOTE why is it a remarkable animal? "
"(default: 'it can speak English')"
) in help_normalised


def test_default_arg_values_in_help__regression():
Expand Down
9 changes: 9 additions & 0 deletions tests/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,12 @@ def func(*, x: TextIO = sys.stdout) -> None:

parser = DebugArghParser()
parser.set_default_command(func)


def test_regression_issue208():
@argh.arg("foo_bar", help="fooooo")
def func(foo_bar):
return foo_bar

parser = DebugArghParser()
parser.set_default_command(func)

0 comments on commit 17d3365

Please sign in to comment.