Skip to content

Fix Rich help terminal width - #1945

Open
AIlord1501 wants to merge 2 commits into
fastapi:masterfrom
AIlord1501:fix-rich-terminal-width
Open

Fix Rich help terminal width#1945
AIlord1501 wants to merge 2 commits into
fastapi:masterfrom
AIlord1501:fix-rich-terminal-width

Conversation

@AIlord1501

Copy link
Copy Markdown

Pull Request

Discussion: #1944

Description

Problem

When Typer renders help using Rich, CliRunner(..., terminal_width=...) was not respected.

The requested terminal width is stored in the Click context as ctx.terminal_width, but the Rich console was using MAX_WIDTH instead. This caused Rich-formatted help output to exceed the terminal width requested by CliRunner.

Fix

Pass ctx.terminal_width to Typer's Rich console when formatting help.

The existing MAX_WIDTH behavior remains the fallback when no explicit width is provided.

Tests

Added a regression test verifying that Rich-formatted help respects the terminal width supplied through CliRunner.

Full test suite:

  • 1384 passed
  • 18 skipped
  • 2 xfailed

AI Disclaimer

This pull request was developed with assistance from an AI coding assistant (GPT-5.6 Luna).

AI transcript

Checklist

  • This PR links to a GitHub Discussion for the proposed code change.
  • I added tests for the change.
  • The new or updated tests fail on the main branch and pass on this PR.
  • Coverage stays at 100%.
  • The documentation explains the change if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants