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__()`.
docstr: :param argument_parser: The argument parser to autocomplete on
  :param always_complete_options:
      Controls the autocompletion of option strings if an option string opening character (normally ``-``) has not
      been entered. If ``True`` (default), both short (``-x``) and long (``--x``) option strings will be
      suggested. If ``False``, no option strings will be suggested. If ``long``, long options and short options
      with no long variant will be suggested. If ``short``, short options and long options with no short variant
      will be suggested.
  :param exit_method:
      Method used to stop the program after printing completions. Defaults to :meth:`os._exit`. If you want to
      perform a normal exit that calls exit handlers, use :meth:`sys.exit`.
  :param exclude: List of strings representing options to be omitted from autocompletion
  :param validator:
      Function to filter all completions through before returning (called with two string arguments, completion
      and prefix; return value is evaluated as a boolean)
  :param print_suppressed:
      Whether or not to autocomplete options that have the ``help=argparse.SUPPRESS`` keyword argument set.
  :param append_space:
      Whether to append a space to unique matches. The default is ``True``.
  
  .. note::
      If you are not subclassing CompletionFinder to override its behaviors,
      use :meth:`argcomplete.autocomplete()` directly. It has the same signature as this method.
  
  Produces tab completions for ``argument_parser``. See module docs for more info.
  
  Argcomplete only executes actions if their class is known not to have side effects. Custom action classes can be
  added to argcomplete.safe_actions, if their values are wanted in the ``parsed_args`` completer argument, or
  their execution is otherwise desirable.
docstr_tok: [":","param","argument_parser",":","The","argument","parser","to","autocomplete","on",":","param","always_complete_options",":","Controls","the","autocompletion","of","option","strings","if","an","option","string","opening","character","(","normally","``","-","``",")","has","not","been","entered",".","If","``","True","``","(","default",")",",","both","short","(","``","-x","``",")","and","long","(","``","--","x","``",")","option","strings","will","be","suggested",".","If","``","False","``",",","no","option","strings","will","be","suggested",".","If","``","long","``",",","long","options","and","short","options","with","no","long","variant","will","be","suggested",".","If","``","short","``",",","short","options","and","long","options","with","no","short","variant","will","be","suggested",".",":","param","exit_method",":","Method","used","to","stop","the","program","after","printing","completions",".","Defaults","to",":","meth",":","`","os._exit","`",".","If","you","want","to","perform","a","normal","exit","that","calls","exit","handlers",",","use",":","meth",":","`","sys.exit","`",".",":","param","exclude",":","List","of","strings","representing","options","to","be","omitted","from","autocompletion",":","param","validator",":","Function","to","filter","all","completions","through","before","returning","(","called","with","two","string","arguments",",","completion","and","prefix",";","return","value","is","evaluated","as","a","boolean",")",":","param","print_suppressed",":","Whether","or","not","to","autocomplete","options","that","have","the","``","help=argparse.SUPPRESS","``","keyword","argument","set",".",":","param","append_space",":","Whether","to","append","a","space","to","unique","matches",".","The","default","is","``","True","``",".","..","note",":",":","If","you","are","not","subclassing","CompletionFinder","to","override","its","behaviors",",","use",":","meth",":","`","argcomplete.autocomplete","(",")","`","directly",".","It","has","the","same","signature","as","this","method",".","Produces","tab","completions","for","``","argument_parser","``",".","See","module","docs","for","more","info",".","Argcomplete","only","executes","actions","if","their","class","is","known","not","to","have","side","effects",".","Custom","action","classes","can","be","added","to","argcomplete.safe_actions",",","if","their","values","are","wanted","in","the","``","parsed_args","``","completer","argument",",","or","their","execution","is","otherwise","desirable","."]
code: def __call__(
      self,
      argument_parser: argparse.ArgumentParser,
      always_complete_options: Union[bool, str] = True,
      exit_method: Callable = os._exit,
      output_stream=None,
      exclude: Optional[Sequence[str]] = None,
      validator: Optional[Callable] = None,
      print_suppressed: bool = False,
      append_space: Optional[bool] = None,
      default_completer=FilesCompleter(),
  ):
      """
      :param argument_parser: The argument parser to autocomplete on
      :param always_complete_options:
          Controls the autocompletion of option strings if an option string opening character (normally ``-``) has not
          been entered. If ``True`` (default), both short (``-x``) and long (``--x``) option strings will be
          suggested. If ``False``, no option strings will be suggested. If ``long``, long options and short options
          with no long variant will be suggested. If ``short``, short options and long options with no short variant
          will be suggested.
      :param exit_method:
          Method used to stop the program after printing completions. Defaults to :meth:`os._exit`. If you want to
          perform a normal exit that calls exit handlers, use :meth:`sys.exit`.
      :param exclude: List of strings representing options to be omitted from autocompletion
      :param validator:
          Function to filter all completions through before returning (called with two string arguments, completion
          and prefix; return value is evaluated as a boolean)
      :param print_suppressed:
          Whether or not to autocomplete options that have the ``help=argparse.SUPPRESS`` keyword argument set.
      :param append_space:
          Whether to append a space to unique matches. The default is ``True``.
  
      .. note::
          If you are not subclassing CompletionFinder to override its behaviors,
          use :meth:`argcomplete.autocomplete()` directly. It has the same signature as this method.
  
      Produces tab completions for ``argument_parser``. See module docs for more info.
  
      Argcomplete only executes actions if their class is known not to have side effects. Custom action classes can be
      added to argcomplete.safe_actions, if their values are wanted in the ``parsed_args`` completer argument, or
      their execution is otherwise desirable.
      """
      self.__init__(  # type: ignore
          argument_parser,
          always_complete_options=always_complete_options,
          exclude=exclude,
          validator=validator,
          print_suppressed=print_suppressed,
          append_space=append_space,
          default_completer=default_completer,
      )
  
      if "_ARGCOMPLETE" not in os.environ:
          # not an argument completion invocation
          return
  
      try:
          _io.debug_stream = os.fdopen(9, "w")
      except Exception:
          _io.debug_stream = sys.stderr
      debug()
  
      if output_stream is None:
          filename = os.environ.get("_ARGCOMPLETE_STDOUT_FILENAME")
          if filename is not None:
              debug("Using output file {}".format(filename))
              output_stream = open(filename, "w")
  
      if output_stream is None:
          try:
              output_stream = os.fdopen(8, "w")
          except Exception:
              debug("Unable to open fd 8 for writing, quitting")
              exit_method(1)
  
      ifs = os.environ.get("_ARGCOMPLETE_IFS", "\013")
      if len(ifs) != 1:
          debug("Invalid value for IFS, quitting [{v}]".format(v=ifs))
          exit_method(1)
  
      dfs = os.environ.get("_ARGCOMPLETE_DFS")
      if dfs and len(dfs) != 1:
          debug("Invalid value for DFS, quitting [{v}]".format(v=dfs))
          exit_method(1)
  
      comp_line = os.environ["COMP_LINE"]
      comp_point = int(os.environ["COMP_POINT"])
  
      (
          cword_prequote,
          cword_prefix,
          cword_suffix,
          comp_words,
          last_wordbreak_pos,
      ) = split_line(comp_line, comp_point)
  
      # _ARGCOMPLETE is set by the shell script to tell us where comp_words
      # should start, based on what we're completing.
      # 1: <script> [args]
      # 2: python <script> [args]
      # 3: python -m <module> [args]
      start = int(os.environ["_ARGCOMPLETE"]) - 1
      comp_words = comp_words[start:]
  
      if (
          cword_prefix
          and cword_prefix[0] in self._parser.prefix_chars
          and "=" in cword_prefix
      ):
          # Special case for when the current word is "--optional=PARTIAL_VALUE". Give the optional to the parser.
          comp_words.append(cword_prefix.split("=", 1)[0])
  
      debug(
          "\nLINE: {!r}".format(comp_line),
          "\nPOINT: {!r}".format(comp_point),
          "\nPREQUOTE: {!r}".format(cword_prequote),
          "\nPREFIX: {!r}".format(cword_prefix),
          "\nSUFFIX: {!r}".format(cword_suffix),
          "\nWORDS:",
          comp_words,
      )
  
      completions = self._get_completions(
          comp_words, cword_prefix, cword_prequote, last_wordbreak_pos
      )
  
      if dfs:
          display_completions = {
              key: value.replace(ifs, " ") if value else ""
              for key, value in self._display_completions.items()
          }
          completions = [
              dfs.join((key, display_completions.get(key) or ""))
              for key in completions
          ]
  
      if os.environ.get("_ARGCOMPLETE_SHELL") == "zsh":
          completions = [
              f"{c}:{self._display_completions.get(c)}"
              for c in completions
          ]
  
      debug("\nReturning completions:", completions)
      output_stream.write(ifs.join(completions))
      output_stream.flush()
      _io.debug_stream.flush()
      exit_method(0)
  
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 2 for calling the CompletionFinder obj's underlying member method code with example usage: obj.__call__(argument_parser, always_complete_options, exit_method, output_stream, exclude, validator, print_suppressed, append_space, default_completer) without return types