-
-
Notifications
You must be signed in to change notification settings - Fork 772
🐛 Avoid printing additional output with no_args_is_help=True
and Click 8.2
#1278
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
A little bit more explanation as to why/how this happens: At L211-220 we have this in
When Rich isn't used, the But when Rich is used, this gets bypassed and in
|
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 all the investigation and clean fix! 🙌 🚀
This is available in Typer 0.16.1, just released. 🎉
Thanks @svlandeg |
Follow-up of #1262
The core issue: running a CLI with the
no_args_is_help
feature enabled displays an error block and a duplicated "Usage" line, whenever Rich ánd Click >= 8.2.0 is used (supported since Typer 0.16.0). The error does not occur without Rich, or with an older version of Click.To replicate, run
python docs_src/commands/index/tutorial003.py
and inspect the console output.There's two aspects to consider here:
Bug fix
Ensure this duplicate print & error message is avoided. Note that we can't import
NoArgsIsHelpError
from Click directly because that would break compatibility with Click 8.0 and 8.1, as this new error type was only introduced in 8.2.0.Potentially breaking behaviour
Decide on the exit code of a function call without arguments but with
no_args_is_help=True
. Should it be 0 (as before) or 2 (as Click is doing since pallets/click#1489)?test_tutorial003.test_no_arg
. We'll then need to add a custom workaround in Typer to change the behaviour compared to what Click does.