Skip to content
Myr

🐛 Fix Rich formatting with no commands (#796)

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 c9bc93c · Browse files · 2 files+16 added−1 removed
This commit

State

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

Diff stats

2 files+16 added−1 removed

  • tests:+14 added−0 removed
  • other:+2 added−1 removed

2 files+16 added−1 removed

modified:tests/test_rich_utils.py+14 added
34 unmodified lines
35 result = runner.invoke(app, ["main"])36 assert "Hello World" in result.stdout37 result = runner.invoke(app, ["secondary"])38 assert "Hello Secondary World" in result.stdout394041def test_rich_help_no_commands():42 """Ensure that the help still works for a Typer instance with no commands, but with a callback."""43 app = typer.Typer(help="My cool Typer app")4445 @app.callback(invoke_without_command=True, no_args_is_help=True)46 def main() -> None:47 return None # pragma: no cover4849 result = runner.invoke(app, ["--help"])5051 assert result.exit_code == 052 assert "Show this message" in result.stdout
modified:typer/rich_utils.py+2 added-1 removed
642 unmodified lines
643 [644 len(command.name or "")645 for commands in panel_to_commands.values()646 for command in commands647 ]647 ],648 default=0,649 )650651 # Print each command group panel652 default_commands = panel_to_commands.get(COMMANDS_PANEL_TITLE, [])
59 unmodified lines