From e01b2939d880cd6a2e55881d18afd9666a80ec8c Mon Sep 17 00:00:00 2001 From: mshzy <156560471+mshzy@users.noreply.github.com> Date: Tue, 2 Jun 2026 10:33:41 +0800 Subject: [PATCH] fix: respect TYPER_USE_RICH in completion help text sanitization _sanitize_help_text checked if Rich is installed but ignored the TYPER_USE_RICH=false environment variable. When users disable Rich, the completion system would still try to import and use it. Fixes #1643. --- typer/_completion_classes.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/typer/_completion_classes.py b/typer/_completion_classes.py index cfae02c9bf..98e9f4960b 100644 --- a/typer/_completion_classes.py +++ b/typer/_completion_classes.py @@ -20,6 +20,9 @@ def _sanitize_help_text(text: str) -> str: """Sanitizes the help text by removing rich tags""" if not importlib.util.find_spec("rich"): return text + # Respect TYPER_USE_RICH environment variable + if os.getenv("TYPER_USE_RICH", "").lower() in ("false", "0", "no", "off"): + return text from . import rich_utils return rich_utils.rich_render_text(text)