🐛 Make sure rich.markup is imported when rendering help text#1290
🐛 Make sure rich.markup is imported when rendering help text#1290tiangolo merged 10 commits intofastapi:masterfrom
rich.markup is imported when rendering help text#1290Conversation
rich.markup is used to escape strings when rendering help texts. This fixes a regression introduced by fastapi#1128
rich.markup is imported when rendering help text
There was a problem hiding this comment.
So just to clarify some edits I just made: The original content of the PR imported rich.markup before using escape, because due to the lazy imports from #1128 this module wasn't available.
I've rewritten this and moved the escaping functionality to rich_utils. My proposal is to never use rich directly in the core library, to isolate all this functionality within rich_utils and avoid any other future regressions.
There's a few more edits and maybe an additional test I'd like to add to this PR, so I'll put this in draft while I continue to work on it.
And thanks for the report & PR, @g-arjones ! 🙏
|
@g-arjones: do you have a minimal example that crashes on |
|
@svlandeg Sure, here you go: from typing import Annotated
import typer
app = typer.Typer(rich_markup_mode=None)
@app.command()
def foo(bar: Annotated[str, typer.Argument(help='foobar')]) -> None:
"""foobar."""
pass
app()Then run with |
|
Thanks! This has been a bit tricky to get into the test suite, because other tests do import I will add one more edit to this PR to fix a similar issue with accessing |
|
Thanks for taking the time! |
rich.markup is used to escape strings when rendering help texts.
This fixes a regression introduced by #1128