Rich help ignores CliRunner terminal_width #1944
Unanswered
AIlord1501
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
First Check
Example Code
Description
When using Typer's Rich help rendering, the terminal_width passed to CliRunner is not respected.
I expected:
to render the Rich help output within the requested terminal width.
Instead, the Rich help output is rendered significantly wider than 40 columns.
I reproduced this locally on the current Typer source.
I also verified that the existing test suite passes and created a regression test demonstrating the behavior.
Operating System
Windows
Operating System Details
Windows 11
PowerShell
Project Version
Current master branch
Python Version
Python 3.12.10
Additional Context
The issue appears specifically in the Rich help rendering path.
The Click context contains the requested terminal_width, but the Rich Console was previously created using MAX_WIDTH instead of the context's terminal_width.
For example, with terminal_width=40, the rendered Rich help panel still extends beyond the requested width.
I also confirmed the behavior with a focused pytest regression test.
Before the change:
After the change:
The relevant change is to propagate ctx.terminal_width to the Rich console used by rich_format_help().
All reactions