🐛 Avoid printing additional output with no_args_is_help=True and Click 8.2#1278
Merged
tiangolo merged 7 commits intofastapi:masterfrom Aug 18, 2025
Merged
🐛 Avoid printing additional output with no_args_is_help=True and Click 8.2#1278tiangolo merged 7 commits intofastapi:masterfrom
no_args_is_help=True and Click 8.2#1278tiangolo merged 7 commits intofastapi:masterfrom
Conversation
Member
Author
|
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
|
tiangolo
approved these changes
Aug 18, 2025
|
Thanks @svlandeg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up of #1262
The core issue: running a CLI with the
no_args_is_helpfeature 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.pyand 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
NoArgsIsHelpErrorfrom 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.