class_docstr: Inherit from this class if you wish to override any of the stages below. Otherwise, use
  ``argcomplete.autocomplete()`` directly (it's a convenience instance of this class). It has the same signature as
  :meth:`CompletionFinder.__call__()`.
code: def _complete_active_option(
      self,
      parser,
      next_positional,
      cword_prefix,
      parsed_args,
      completions,
  ):
      debug(
          "Active actions (L={l}): {a}".format(
              l=len(parser.active_actions), a=parser.active_actions
          )
      )
  
      isoptional = (
          cword_prefix and cword_prefix[0] in parser.prefix_chars
      )
      optional_prefix = ""
      greedy_actions = [
          x
          for x in parser.active_actions
          if action_is_greedy(x, isoptional)
      ]
      if greedy_actions:
          assert (
              len(greedy_actions) == 1
          ), "expect at most 1 greedy action"
          # This means the action will fail to parse if the word under the cursor is not given
          # to it, so give it exclusive control over completions (flush previous completions)
          debug(
              "Resetting completions because",
              greedy_actions[0],
              "must consume the next argument",
          )
          self._display_completions = {}
          completions = []
      elif isoptional:
          if "=" in cword_prefix:
              # Special case for when the current word is "--optional=PARTIAL_VALUE".
              # The completer runs on PARTIAL_VALUE. The prefix is added back to the completions
              # (and chopped back off later in quote_completions() by the COMP_WORDBREAKS logic).
              optional_prefix, _, cword_prefix = cword_prefix.partition(
                  "="
              )
          else:
              # Only run completers if current word does not start with - (is not an optional)
              return completions
  
      complete_remaining_positionals = False
      # Use the single greedy action (if there is one) or all active actions.
      for active_action in greedy_actions or parser.active_actions:
          if not active_action.option_strings:  # action is a positional
              if action_is_open(active_action):
                  # Any positional arguments after this may slide down into this action
                  # if more arguments are added (since the user may not be done yet),
                  # so it is extremely difficult to tell which completers to run.
                  # Running all remaining completers will probably show more than the user wants
                  # but it also guarantees we won't miss anything.
                  complete_remaining_positionals = True
              if not complete_remaining_positionals:
                  if action_is_satisfied(
                      active_action
                  ) and not action_is_open(active_action):
                      debug("Skipping", active_action)
                      continue
  
          debug(
              "Activating completion for",
              active_action,
              active_action._orig_class,
          )
          # completer = getattr(active_action, "completer", DefaultCompleter())
          completer = getattr(active_action, "completer", None)
  
          if completer is None:
              if active_action.choices is not None and not isinstance(
                  active_action, argparse._SubParsersAction
              ):
                  completer = ChoicesCompleter(active_action.choices)
              elif not isinstance(
                  active_action, argparse._SubParsersAction
              ):
                  completer = self.default_completer
  
          if completer:
              if (
                  isinstance(completer, SuppressCompleter)
                  and completer.suppress()
              ):
                  continue
  
              if callable(completer):
                  completer_output = completer(
                      prefix=cword_prefix,
                      action=active_action,
                      parser=parser,
                      parsed_args=parsed_args,
                  )
                  if isinstance(completer_output, Mapping):
                      for (
                          completion,
                          description,
                      ) in completer_output.items():
                          if self.validator(completion, cword_prefix):
                              completions.append(completion)
                              self._display_completions[
                                  completion
                              ] = description
                  else:
                      for completion in completer_output:
                          if self.validator(completion, cword_prefix):
                              completions.append(completion)
                              if isinstance(
                                  completer, ChoicesCompleter
                              ):
                                  self._display_completions[
                                      completion
                                  ] = (active_action.help or "")
                              else:
                                  self._display_completions[
                                      completion
                                  ] = ""
              else:
                  debug(
                      "Completer is not callable, trying the readline completer protocol instead"
                  )
                  for i in range(9999):
                      next_completion = completer.complete(cword_prefix, i)  # type: ignore
                      if next_completion is None:
                          break
                      if self.validator(next_completion, cword_prefix):
                          self._display_completions[
                              next_completion
                          ] = ""
                          completions.append(next_completion)
              if optional_prefix:
                  completions = [
                      optional_prefix + "=" + completion
                      for completion in completions
                  ]
              debug("Completions:", completions)
      return completions
  
imports: import argparse
  import os
  import sys
  from collections.abc import Mapping
  from typing import Callable, Dict, List, Optional, Sequence, Union
  from .None import io
  from .completers import ChoicesCompleter, FilesCompleter, SuppressCompleter
  from .io import debug, mute_stderr
  from .lexers import split_line
  from .packages._argparse import IntrospectiveArgumentParser, action_is_greedy, action_is_open, action_is_satisfied
label_desc: Use image node_id 9 for calling the CompletionFinder obj's underlying member method code with example usage: obj._complete_active_option(parser, next_positional, cword_prefix, parsed_args, completions) and returns: completions, completions