Skip to content

Commit 119c476

Browse files
authored
Make sure 'rich.markup' is imported when rendering help text
rich.markup is used to escape strings when rendering help texts. This fixes a regression introduced by fastapi#1128
1 parent 9c5c543 commit 119c476

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

typer/core.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ def get_help_record(self, ctx: click.Context) -> Optional[Tuple[str, str]]:
372372
extra_str = f"[{extra_str}]"
373373
if rich is not None:
374374
# This is needed for when we want to export to HTML
375+
import rich.markup
375376
extra_str = rich.markup.escape(extra_str).strip()
376377

377378
help = f"{help} {extra_str}" if help else f"{extra_str}"
@@ -583,6 +584,7 @@ def _write_opts(opts: Sequence[str]) -> str:
583584
extra_str = f"[{extra_str}]"
584585
if rich is not None:
585586
# This is needed for when we want to export to HTML
587+
import rich.markup
586588
extra_str = rich.markup.escape(extra_str).strip()
587589

588590
help = f"{help} {extra_str}" if help else f"{extra_str}"

0 commit comments

Comments
 (0)