From 52e600124755f3ef16c2a7c57786832216d53d35 Mon Sep 17 00:00:00 2001 From: GueLaKais Date: Sat, 29 Jun 2024 13:08:05 +0200 Subject: [PATCH] added comments to the argcompleter method --- .../argcomplete_completer/cargo_args.py | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/colcon_cargo/argcomplete_completer/cargo_args.py b/colcon_cargo/argcomplete_completer/cargo_args.py index 53d5cc4..17466bf 100644 --- a/colcon_cargo/argcomplete_completer/cargo_args.py +++ b/colcon_cargo/argcomplete_completer/cargo_args.py @@ -20,7 +20,25 @@ def __init__(self): # noqa: D107 ArgcompleteCompleterExtensionPoint.EXTENSION_POINT_VERSION, '^1.0') def get_completer(self, parser, *args, **kwargs): # noqa: D102 - if '--cargo-args' not in args: + """ + Get the completer for Cargo arguments. + + This method checks if the '--cargo-args' argument is present in the provided arguments. + If it is, it tries to import the ChoicesCompleter from the argcomplete package and returns + an instance of it with an empty list of choices. If the '--cargo-args' argument is not + present or the argcomplete package is not installed, it returns None. + + Args: + parser: The argument parser. + *args: Positional arguments passed to the method. + **kwargs: Keyword arguments passed to the method. + + Returns: + ChoicesCompleter or None: An instance of ChoicesCompleter with an empty list of choices, + or None if the '--cargo-args' argument is not present or the argcomplete package is not + installed. + """ + if "--cargo-args" not in args: return None try: