-
-
Notifications
You must be signed in to change notification settings - Fork 781
🐛 Make sure rich.markup
is imported when rendering help text
#1290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the report and fix! 🍰
And thanks @svlandeg for the tweaks, confirmation, test... 🙌
This will be available in Typer 0.17.4 released in the next few minutes. 🎉
rich.markup is used to escape strings when rendering help texts.
This fixes a regression introduced by #1128