Skip to content

Conversation

mmakaay
Copy link

@mmakaay mmakaay commented Jul 28, 2025

Since typer 0.16.0, running a CLI with the no_args_is_help feature enabled displays an error block. The patch from the PR suppresses the duplicate Usage: info and the Error output block, in case the processed exception is a NoArgsIsHelperror.

Example with invalid output (based on the no_args_is_help example code)

image

Output with this patch applied:

image

Maurice Makaay and others added 2 commits July 28, 2025 20:04
Since typer 0.16.0, running a CLI with the no_args_is_help feature
enabled displays an error block, e.g. for my application:

 Usage: myapp [OPTIONS] COMMAND [ARGS]...

 This is the CLI for my app

╭─ Options ─────────────────────────────────────────────────────────╮
│ --verbose  -v        Use multiple times for more verbosity.       │
│ --help               Show this message and exit.                  │
╰───────────────────────────────────────────────────────────────────╯
╭─ Commands ────────────────────────────────────────────────────────╮
│ version   Show application version.                               │
│ run       Start the application.                                  │
╰───────────────────────────────────────────────────────────────────╯
Usage: authsync [OPTIONS] COMMAND [ARGS]...
Try 'authsync --help' for help.
╭─ Error ───────────────────────────────────────────────────────────╮
│                                                                   │
╰───────────────────────────────────────────────────────────────────╯

The patch from the PR suppresses the duplicate Usage: info and the Error
output block, in case the processed exception is a NoArgsIsHelperror.
@j-standfast
Copy link

+1 (as in, I'm seeing the same issue using Typer v0.16.0)

@AleksBelytskyi
Copy link

+1 (the same issue here)

@svlandeg svlandeg self-assigned this Aug 18, 2025
@svlandeg svlandeg added the bug Something isn't working label Aug 18, 2025
@svlandeg svlandeg changed the title Fix the output for no_args_is_help=True 🐛 Fix the output for no_args_is_help=True Aug 18, 2025
Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

thanks for the report!

I can confirm the issue in an environment with Click 8.2.

However, we need to support also earlier versions of 8.0 and 8.1, and NoArgsIsHelpError has only been introduced in Click 8.2. So we can't have this direct import and we'll need to search for another (and hopefully elegant) way to resolve this bug instead.

@svlandeg svlandeg marked this pull request as draft August 18, 2025 09:39
@svlandeg svlandeg changed the title 🐛 Fix the output for no_args_is_help=True 🐛 Fix the output for no_args_is_help=True with Click 8.2 Aug 18, 2025
@svlandeg svlandeg removed their assignment Aug 18, 2025
@svlandeg
Copy link
Member

Note that in the meantime, you can avoid this bug by restricting Click to < 8.2.

@svlandeg
Copy link
Member

svlandeg commented Aug 18, 2025

@mmakaay: thanks again for your work on this!

I'm closing this PR in favour of #1278 which has a unit test, some additional explanations and a different fix with a more narrow scope (in rich_utils.py instead of in core.py) which also keeps compatibility with older Click versions.

I'd appreciate your review on this new PR if you have time! [edit: it's already merged in the meantime 🙈]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants