From b981ca99ed7891447db13420d39462e4d7d367ac Mon Sep 17 00:00:00 2001 From: Mr-Neutr0n <64578610+Mr-Neutr0n@users.noreply.github.com> Date: Sat, 14 Feb 2026 08:57:07 +0530 Subject: [PATCH] fix help hint showing shadowed option name when a subcommand option shadows a help option name (e.g. -h), the error hint was still suggesting the shadowed name. now it uses get_help_option_names() which filters out names claimed by other options, so it picks a working alternative like --help. --- src/click/exceptions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/click/exceptions.py b/src/click/exceptions.py index 4d782ee361..e2add54ed5 100644 --- a/src/click/exceptions.py +++ b/src/click/exceptions.py @@ -78,8 +78,9 @@ def show(self, file: t.IO[t.Any] | None = None) -> None: self.ctx is not None and self.ctx.command.get_help_option(self.ctx) is not None ): + help_names = self.ctx.command.get_help_option_names(self.ctx) hint = _("Try '{command} {option}' for help.").format( - command=self.ctx.command_path, option=self.ctx.help_option_names[0] + command=self.ctx.command_path, option=help_names[0] ) hint = f"{hint}\n" if self.ctx is not None: