class_docstr: An extension of CompletionFinder which dynamically completes class-trait based options
  
  This finder adds a few functionalities:
  
  1. When completing options, it will add ``--Class.`` to the list of completions, for each
  class in `Application.classes` that could complete the current option.
  2. If it detects that we are currently trying to complete an option related to ``--Class.``,
  it will add the corresponding config traits of Class to the `ArgumentParser` instance,
  so that the traits' completers can be used.
  3. If there are any subcommands, they are added as completions for the first word
  
  Note that we are avoiding adding all config traits of all classes to the `ArgumentParser`,
  which would be easier but would add more runtime overhead and would also make completions
  appear more spammy.
  
  These changes do require using the internals of `argcomplete.CompletionFinder`.
class_docstr_tok: ["An","extension","of","CompletionFinder","which","dynamically","completes","class-trait","based","options","This","finder","adds","a","few","functionalities",":","1",".","When","completing","options",",","it","will","add","``","--","Class.","``","to","the","list","of","completions",",","for","each","class","in","`","Application.classes","`","that","could","complete","the","current","option",".","2",".","If","it","detects","that","we","are","currently","trying","to","complete","an","option","related","to","``","--","Class.","``",",","it","will","add","the","corresponding","config","traits","of","Class","to","the","`","ArgumentParser","`","instance",",","so","that","the","traits","'","completers","can","be","used",".","3",".","If","there","are","any","subcommands",",","they","are","added","as","completions","for","the","first","word","Note","that","we","are","avoiding","adding","all","config","traits","of","all","classes","to","the","`","ArgumentParser","`",",","which","would","be","easier","but","would","add","more","runtime","overhead","and","would","also","make","completions","appear","more","spammy",".","These","changes","do","require","using","the","internals","of","`","argcomplete.CompletionFinder","`","."]
docstr: Add dummy arguments to our ArgumentParser for the traits of this class
  
  The argparse-based loader currently does not actually add any class traits to
  the constructed ArgumentParser, only the flags & aliaes. In order to work nicely
  with argcomplete's completers functionality, this method adds dummy arguments
  of the form --Class.trait to the ArgumentParser instance.
  
  This method should be called selectively to reduce runtime overhead and to avoid
  spamming options across all of Application.classes.
docstr_tok: ["Add","dummy","arguments","to","our","ArgumentParser","for","the","traits","of","this","class","The","argparse-based","loader","currently","does","not","actually","add","any","class","traits","to","the","constructed","ArgumentParser",",","only","the","flags","&","aliaes",".","In","order","to","work","nicely","with","argcomplete","'s","completers","functionality",",","this","method","adds","dummy","arguments","of","the","form","--","Class.trait","to","the","ArgumentParser","instance",".","This","method","should","be","called","selectively","to","reduce","runtime","overhead","and","to","avoid","spamming","options","across","all","of","Application.classes","."]
code: def inject_class_to_parser(self, cls: t.Any) -> None:
      """Add dummy arguments to our ArgumentParser for the traits of this class
  
      The argparse-based loader currently does not actually add any class traits to
      the constructed ArgumentParser, only the flags & aliaes. In order to work nicely
      with argcomplete's completers functionality, this method adds dummy arguments
      of the form --Class.trait to the ArgumentParser instance.
  
      This method should be called selectively to reduce runtime overhead and to avoid
      spamming options across all of Application.classes.
      """
      try:
          for traitname, trait in cls.class_traits(config=True).items():
              completer = trait.metadata.get("argcompleter") or getattr(
                  trait, "argcompleter", None
              )
              multiplicity = trait.metadata.get("multiplicity")
              self._parser.add_argument(  # type: ignore[attr-defined]
                  f"--{cls.__name__}.{traitname}",
                  type=str,
                  help=trait.help,
                  nargs=multiplicity,
                  # metavar=traitname,
              ).completer = completer
              # argcomplete.debug(f"added --{cls.__name__}.{traitname}")
      except AttributeError:
          pass
  
file_path: catboost/contrib/python/traitlets/py3/traitlets/config/argcomplete_config.py
imports: import argparse
  import os
  import typing
label_desc: Use image node_id 2 for calling the ExtendedCompletionFinder obj's underlying member method code with example usage: obj.inject_class_to_parser(cls) without return types