Skip to content

Commit

Permalink
"Perhaps you meant:"
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Sep 7, 2023
1 parent bb20982 commit 3324036
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "tyro"
authors = [
{name = "brentyi", email = "[email protected]"},
]
version = "0.5.7"
version = "0.5.8"
description = "Strongly typed, zero-effort CLI interfaces"
readme = "README.md"
license = { text="MIT" }
Expand Down
12 changes: 6 additions & 6 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class Class:

error = target.getvalue()
assert "Unrecognized argument" in error
assert "Similar arguments" in error
assert "Perhaps you meant:" in error

# --reward.track should appear in both the usage string and as a similar argument.
assert error.count("--reward.track") == 1
Expand All @@ -193,7 +193,7 @@ class ClassB:

error = target.getvalue()
assert "Unrecognized argument" in error
assert "Similar arguments:" in error
assert "Perhaps you meant::" in error
assert error.count("--reward.track") == 1
assert error.count("--help") == 3

Expand Down Expand Up @@ -244,7 +244,7 @@ class ClassB:

error = target.getvalue()
assert "Unrecognized argument" in error
assert "Similar arguments" in error
assert "Perhaps you meant:" in error
assert error.count("--reward.track {True,False}") == 1
assert error.count("--reward.trace INT") == 1
assert error.count("--help") == 5 # 2 subcommands * 2 arguments + usage hint.
Expand All @@ -270,7 +270,7 @@ class ClassB:

error = target.getvalue()
assert "Unrecognized argument" in error
assert "Similar arguments" in error
assert "Perhaps you meant:" in error
assert error.count("--reward.track {True,False}") == 1
assert (
error.count("--help") == 3
Expand Down Expand Up @@ -312,7 +312,7 @@ class ClassB:

error = target.getvalue()
assert "Unrecognized argument" in error
assert "Similar arguments" in error
assert "Perhaps you meant:" in error
assert error.count("--reward.track") == 10
assert "[...]" not in error
assert error.count("--help") == 21
Expand Down Expand Up @@ -380,7 +380,7 @@ class ClassI:

error = target.getvalue()
assert "Unrecognized argument" in error
assert "Similar arguments" in error
assert "Perhaps you meant:" in error
assert error.count("--reward.track") == 1
assert "[...]" in error
assert error.count("--help") == 5
Expand Down
2 changes: 1 addition & 1 deletion tyro/_argparse_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ def get_score(option_string: str) -> float:
# Add a header before the first similar argument.
extra_info.append(Rule(style=Style(color="red")))
extra_info.append(
"Similar arguments:"
"Perhaps you meant:"
if len(unrecognized_arguments) == 1
else f"Arguments similar to {unrecognized_argument}:"
)
Expand Down

0 comments on commit 3324036

Please sign in to comment.