Browse Source

Update contrib/python/traitlets/py3 to 5.14.0

robot-contrib 1 year ago
parent
commit
1823321f2d

+ 2 - 2
contrib/python/traitlets/py3/.dist-info/METADATA

@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: traitlets
-Version: 5.13.0
+Version: 5.14.0
 Summary: Traitlets Python configuration system
 Project-URL: Homepage, https://github.com/ipython/traitlets
 Project-URL: Documentation, https://traitlets.readthedocs.io
@@ -56,7 +56,7 @@ Requires-Dist: pydata-sphinx-theme; extra == 'docs'
 Requires-Dist: sphinx; extra == 'docs'
 Provides-Extra: test
 Requires-Dist: argcomplete>=3.0.3; extra == 'test'
-Requires-Dist: mypy>=1.6.0; extra == 'test'
+Requires-Dist: mypy>=1.7.0; extra == 'test'
 Requires-Dist: pre-commit; extra == 'test'
 Requires-Dist: pytest-mock; extra == 'test'
 Requires-Dist: pytest-mypy-testing; extra == 'test'

+ 2 - 2
contrib/python/traitlets/py3/tests/test_typing.py

@@ -102,9 +102,9 @@ def mypy_list_typing() -> None:
     t = T()
     reveal_type(List(["foo"]))  # R: traitlets.traitlets.List[builtins.str]
     reveal_type(List([""]).tag(sync=True))  # R: traitlets.traitlets.List[builtins.str]
-    reveal_type(List(None, allow_none=True))  # R: traitlets.traitlets.List[<nothing>]
+    reveal_type(List(None, allow_none=True))  # R: traitlets.traitlets.List[Never]
     reveal_type(
-        List(None, allow_none=True).tag(sync=True)  # R: traitlets.traitlets.List[<nothing>]
+        List(None, allow_none=True).tag(sync=True)  # R: traitlets.traitlets.List[Never]
     )
     reveal_type(T.latex_command)  # R: traitlets.traitlets.List[builtins.str]
     reveal_type(t.latex_command)  # R: builtins.list[builtins.str]

+ 1 - 1
contrib/python/traitlets/py3/traitlets/_version.py

@@ -5,7 +5,7 @@ import re
 from typing import List
 
 # Version string must appear intact for hatch versioning
-__version__ = "5.13.0"
+__version__ = "5.14.0"
 
 # Build up version_info tuple for backwards compatibility
 pattern = r"(?P<major>\d+).(?P<minor>\d+).(?P<patch>\d+)(?P<rest>.*)"

+ 27 - 3
contrib/python/traitlets/py3/traitlets/config/application.py

@@ -23,6 +23,7 @@ from traitlets.config.loader import (
     ArgumentError,
     Config,
     ConfigFileNotFound,
+    DeferredConfigString,
     JSONFileConfigLoader,
     KVArgParseConfigLoader,
     PyFileConfigLoader,
@@ -96,7 +97,7 @@ else:
 IS_PYTHONW = sys.executable and sys.executable.endswith("pythonw.exe")
 
 T = t.TypeVar("T", bound=t.Callable[..., t.Any])
-AnyLogger = t.Union[logging.Logger, logging.LoggerAdapter]
+AnyLogger = t.Union[logging.Logger, "logging.LoggerAdapter[t.Any]"]
 StrDict = t.Dict[str, t.Any]
 ArgvType = t.Optional[t.List[str]]
 ClassesType = t.List[t.Type[Configurable]]
@@ -713,12 +714,12 @@ class Application(SingletonConfigurable):
             self.subapp = subapp.instance(parent=self)
         elif callable(subapp):
             # or ask factory to create it...
-            self.subapp = subapp(self)  # type:ignore[call-arg]
+            self.subapp = subapp(self)
         else:
             raise AssertionError("Invalid mappings for subcommand '%s'!" % subc)
 
         # ... and finally initialize subapp.
-        self.subapp.initialize(argv)  # type:ignore[union-attr]
+        self.subapp.initialize(argv)
 
     def flatten_flags(self) -> tuple[dict[str, t.Any], dict[str, t.Any]]:
         """Flatten flags and aliases for loaders, so cl-args override as expected.
@@ -970,6 +971,29 @@ class Application(SingletonConfigurable):
         new_config.merge(self.cli_config)
         self.update_config(new_config)
 
+    @catch_config_error
+    def load_config_environ(self) -> None:
+        """Load config files by environment."""
+
+        PREFIX = self.name.upper()
+        new_config = Config()
+
+        self.log.debug('Looping through config variables with prefix "%s"', PREFIX)
+
+        for k, v in os.environ.items():
+            if k.startswith(PREFIX):
+                self.log.debug('Seeing environ "%s"="%s"', k, v)
+                # use __ instead of . as separator in env variable.
+                # Warning, case sensitive !
+                _, *path, key = k.split("__")
+                section = new_config
+                for p in path:
+                    section = section[p]
+                setattr(section, key, DeferredConfigString(v))
+
+        new_config.merge(self.cli_config)
+        self.update_config(new_config)
+
     def _classes_with_config_traits(
         self, classes: ClassesType | None = None
     ) -> t.Generator[type[Configurable], None, None]:

+ 3 - 3
contrib/python/traitlets/py3/traitlets/config/argcomplete_config.py

@@ -45,7 +45,7 @@ def get_argcomplete_cwords() -> t.Optional[t.List[str]]:
             cword_suffix,
             comp_words,
             last_wordbreak_pos,
-        ) = argcomplete.split_line(comp_line, comp_point)  # type:ignore[attr-defined]
+        ) = argcomplete.split_line(comp_line, comp_point)  # type:ignore[attr-defined,no-untyped-call]
     except ModuleNotFoundError:
         return None
 
@@ -73,7 +73,7 @@ def increment_argcomplete_index() -> None:
         os.environ["_ARGCOMPLETE"] = str(int(os.environ["_ARGCOMPLETE"]) + 1)
     except Exception:
         try:
-            argcomplete.debug("Unable to increment $_ARGCOMPLETE", os.environ["_ARGCOMPLETE"])  # type:ignore[attr-defined]
+            argcomplete.debug("Unable to increment $_ARGCOMPLETE", os.environ["_ARGCOMPLETE"])  # type:ignore[attr-defined,no-untyped-call]
         except (KeyError, ModuleNotFoundError):
             pass
 
@@ -196,7 +196,7 @@ class ExtendedCompletionFinder(CompletionFinder):
         # Instead, check if comp_words only consists of the script,
         # if so check if any subcommands start with cword_prefix.
         if self.subcommands and len(comp_words) == 1:
-            argcomplete.debug("Adding subcommands for", cword_prefix)  # type:ignore[attr-defined]
+            argcomplete.debug("Adding subcommands for", cword_prefix)  # type:ignore[attr-defined,no-untyped-call]
             completions.extend(subc for subc in self.subcommands if subc.startswith(cword_prefix))
 
         return completions

+ 1 - 1
contrib/python/traitlets/py3/ya.make

@@ -4,7 +4,7 @@ PY3_LIBRARY()
 
 PROVIDES(python_traitlets)
 
-VERSION(5.13.0)
+VERSION(5.14.0)
 
 LICENSE(BSD-3-Clause)