Skip to content
Myr

🐛 Avoid printing additional output with `no_args_is_help=True` and Click 8.2 (#1278)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sofie Van Landeghem · committed by GitHub · parent 55f190e · Browse files · 2 files+11 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

Diff stats

2 files+11 added−0 removed

  • tests:+7 added−0 removed
  • other:+4 added−0 removed

2 files+11 added−0 removed

modified:tests/test_tutorial/test_commands/test_index/test_tutorial003.py+7 added
16 unmodified lines
17 assert "create" in result.output18 assert "delete" in result.output192021def test_no_additional_output():22 """Ensure that no additional output was generated (cf. PR #1262)"""23 result = runner.invoke(app)24 assert result.output.count("Usage") == 125 assert "Error" not in result.output262728def test_create():29 result = runner.invoke(app, ["create"])30 assert result.exit_code == 031 assert "Creating user: Hiro Hamada" in result.output
15 unmodified lines
modified:typer/rich_utils.py+4 added
691 unmodified lines
692693 Called by custom exception handler to print richly formatted click errors.694 Mimics original click.ClickException.echo() function but with rich formatting.695 """696 # Don't do anything when it's a NoArgsIsHelpError (without importing it, cf. #1278)697 if self.__class__.__name__ == "NoArgsIsHelpError":698 return699700 console = _get_rich_console(stderr=True)701 ctx: Union[click.Context, None] = getattr(self, "ctx", None)702 if ctx is not None:703 console.print(ctx.get_usage())
42 unmodified lines