MCPcopy Create free account
hub / github.com/ipython/traitlets / load_config

Method load_config

traitlets/config/loader.py:858–897  ·  view source on GitHub ↗

Parse command line arguments and return as a Config object. Parameters ---------- argv : optional, list If given, a list with the structure of sys.argv[1:] to parse arguments from. If not given, the instance's self.argv attribute (given at

(
        self,
        argv: list[str] | None = None,
        aliases: t.Any = None,
        flags: t.Any = _deprecated,
        classes: t.Any = None,
    )

Source from the content-addressed store, hash-verified

856 self.parser_kw = kwargs
857
858 def load_config(
859 self,
860 argv: list[str] | None = None,
861 aliases: t.Any = None,
862 flags: t.Any = _deprecated,
863 classes: t.Any = None,
864 ) -> Config:
865 """Parse command line arguments and return as a Config object.
866
867 Parameters
868 ----------
869 argv : optional, list
870 If given, a list with the structure of sys.argv[1:] to parse
871 arguments from. If not given, the instance's self.argv attribute
872 (given at construction time) is used.
873 flags
874 Deprecated in traitlets 5.0, instantiate the config loader with the flags.
875
876 """
877
878 if flags is not _deprecated:
879 warnings.warn(
880 "The `flag` argument to load_config is deprecated since Traitlets "
881 f"5.0 and will be ignored, pass flags the `{type(self)}` constructor.",
882 DeprecationWarning,
883 stacklevel=2,
884 )
885
886 self.clear()
887 if argv is None:
888 argv = self.argv
889 if aliases is not None:
890 self.aliases = aliases
891 if classes is not None:
892 self.classes = classes
893 self._create_parser()
894 self._argcomplete(self.classes, self.subcommands)
895 self._parse_args(argv)
896 self._convert_to_config()
897 return self.config
898
899 def get_extra_args(self) -> list[str]:
900 if hasattr(self, "extra_args"):

Callers

nothing calls this directly

Calls 6

_create_parserMethod · 0.95
_argcompleteMethod · 0.95
_parse_argsMethod · 0.95
_convert_to_configMethod · 0.95
warnMethod · 0.80
clearMethod · 0.80

Tested by

no test coverage detected