From 49024c14cb26e5eed73393966336bcaf62796694 Mon Sep 17 00:00:00 2001 From: jorenham Date: Mon, 18 May 2026 16:03:45 +0200 Subject: [PATCH] Add type annotations for instance attributes in `shell_completion` --- src/click/shell_completion.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/click/shell_completion.py b/src/click/shell_completion.py index 7235f1009c..6879139bc3 100644 --- a/src/click/shell_completion.py +++ b/src/click/shell_completion.py @@ -225,6 +225,11 @@ class ShellComplete: be provided by subclasses. """ + cli: Command + ctx_args: cabc.MutableMapping[str, t.Any] + prog_name: str + complete_var: str + def __init__( self, cli: Command, @@ -308,8 +313,8 @@ def complete(self) -> str: class BashComplete(ShellComplete): """Shell completion for Bash.""" - name = "bash" - source_template = _SOURCE_BASH + name: t.ClassVar[str] = "bash" + source_template: t.ClassVar[str] = _SOURCE_BASH @staticmethod def _check_version() -> None: @@ -367,8 +372,8 @@ def format_completion(self, item: CompletionItem) -> str: class ZshComplete(ShellComplete): """Shell completion for Zsh.""" - name = "zsh" - source_template = _SOURCE_ZSH + name: t.ClassVar[str] = "zsh" + source_template: t.ClassVar[str] = _SOURCE_ZSH def get_completion_args(self) -> tuple[list[str], str]: cwords = split_arg_string(os.environ["COMP_WORDS"]) @@ -403,8 +408,8 @@ def format_completion(self, item: CompletionItem) -> str: class FishComplete(ShellComplete): """Shell completion for Fish.""" - name = "fish" - source_template = _SOURCE_FISH + name: t.ClassVar[str] = "fish" + source_template: t.ClassVar[str] = _SOURCE_FISH def get_completion_args(self) -> tuple[list[str], str]: cwords = split_arg_string(os.environ["COMP_WORDS"])