Browse Source

Update contrib/python/traitlets/py3 to 5.12.0

robot-contrib 1 year ago
parent
commit
fd01b46f68

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

@@ -1,8 +1,12 @@
 Metadata-Version: 2.1
 Name: traitlets
-Version: 5.11.2
+Version: 5.12.0
 Summary: Traitlets Python configuration system
 Project-URL: Homepage, https://github.com/ipython/traitlets
+Project-URL: Documentation, https://traitlets.readthedocs.io
+Project-URL: Source, https://github.com/ipython/traitlets
+Project-URL: Funding, https://numfocus.org
+Project-URL: Tracker, https://github.com/ipython/traitlets/issues
 Author-email: IPython Development Team <ipython-dev@python.org>
 License: BSD 3-Clause License
         
@@ -36,12 +40,15 @@ License: BSD 3-Clause License
         OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 License-File: LICENSE
 Keywords: Interactive,Interpreter,Shell,Web
+Classifier: Framework :: IPython
+Classifier: Framework :: Jupyter
 Classifier: Intended Audience :: Developers
 Classifier: Intended Audience :: Science/Research
 Classifier: Intended Audience :: System Administrators
 Classifier: License :: OSI Approved :: BSD License
 Classifier: Programming Language :: Python
 Classifier: Programming Language :: Python :: 3
+Classifier: Typing :: Typed
 Requires-Python: >=3.8
 Provides-Extra: docs
 Requires-Dist: myst-parser; extra == 'docs'
@@ -49,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.5.1; extra == 'test'
+Requires-Dist: mypy>=1.6.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/_warnings.py

@@ -38,7 +38,7 @@ def all_warnings():
     """
 
     # Whenever a warning is triggered, Python adds a __warningregistry__
-    # member to the *calling* module.  The exercize here is to find
+    # member to the *calling* module.  The exercise here is to find
     # and eradicate all those breadcrumbs that were left lying around.
     #
     # We proceed by first searching all parent calling frames and explicitly
@@ -88,7 +88,7 @@ def expected_warnings(matching):
     Raises a ValueError if any match was not found or an unexpected
     warning was raised.
     Allows for three types of behaviors: "and", "or", and "optional" matches.
-    This is done to accomodate different build enviroments or loop conditions
+    This is done to accommodate different build environments or loop conditions
     that may produce different warnings.  The behaviors can be combined.
     If you pass multiple patterns, you get an orderless "and", where all of the
     warnings must be raised.

+ 2 - 7
contrib/python/traitlets/py3/tests/config/test_application.py

@@ -14,7 +14,7 @@ import sys
 import typing as t
 from io import StringIO
 from tempfile import TemporaryDirectory
-from unittest import TestCase
+from unittest import TestCase, mock
 
 import pytest
 from pytest import mark
@@ -25,11 +25,6 @@ from traitlets.config.configurable import Configurable
 from traitlets.config.loader import Config, KVArgParseConfigLoader
 from traitlets.tests.utils import check_help_all_output, check_help_output, get_output_error_code
 
-try:
-    from unittest import mock
-except ImportError:
-    from unittest import mock
-
 pjoin = os.path.join
 
 
@@ -665,7 +660,7 @@ class TestApplication(TestCase):
             with self.assertRaises(AttributeError):
                 app.loaded_config_files = "/foo"  # type:ignore
 
-            # ensure it can't be udpated via append
+            # ensure it can't be updated via append
             app.loaded_config_files.append("/bar")
             self.assertEqual(len(app.loaded_config_files), 1)
 

+ 4 - 4
contrib/python/traitlets/py3/tests/config/test_loader.py

@@ -629,7 +629,7 @@ class TestConfig(TestCase):
         """
         With multiple config files (systemwide and users), we want compounding.
 
-        If systemwide overwirte and user append, we want both in the right
+        If systemwide overwrite and user append, we want both in the right
         order.
         """
         c1 = Config()
@@ -702,7 +702,7 @@ class TestConfig(TestCase):
         """
         With multiple config files (systemwide and users), we want compounding.
 
-        dict update shoudl be in the right order.
+        dict update should be in the right order.
         """
         c1 = Config()
         c2 = Config()
@@ -720,7 +720,7 @@ class TestConfig(TestCase):
         """
         With multiple config files (systemwide and users), we want compounding.
 
-        Later dict overwrite lazyness
+        Later dict overwrite laziness
         """
         c1 = Config()
         c2 = Config()
@@ -738,7 +738,7 @@ class TestConfig(TestCase):
         """
         With multiple config files (systemwide and users), we want compounding.
 
-        Later dict overwrite lazyness
+        Later dict overwrite laziness
         """
         c1 = Config()
         c2 = Config()

+ 6 - 6
contrib/python/traitlets/py3/tests/test_traitlets.py

@@ -2013,7 +2013,7 @@ class TestLink(TestCase):
         a = A(value=9)
         b = A(value=8)
 
-        # Conenct the two classes.
+        # Connect the two classes.
         c = link((a, "value"), (b, "value"))
 
         # Make sure the values are the same at the point of linking.
@@ -2038,7 +2038,7 @@ class TestLink(TestCase):
         a = A(value=9)
         b = B(count=8)
 
-        # Conenct the two classes.
+        # Connect the two classes.
         c = link((a, "value"), (b, "count"))
 
         # Make sure the values are the same at the point of linking.
@@ -2126,7 +2126,7 @@ class TestLink(TestCase):
         a = A(value=9)
         b = A(value=8)
 
-        # Conenct the two classes.
+        # Connect the two classes.
         c = link((a, "value"), (b, "value"), transform=(lambda x: 2 * x, lambda x: int(x / 2.0)))
 
         # Make sure the values are correct at the point of linking.
@@ -2178,7 +2178,7 @@ class TestDirectionalLink(TestCase):
         a = A(value=9)
         b = A(value=8)
 
-        # Conenct the two classes.
+        # Connect the two classes.
         c = directional_link((a, "value"), (b, "value"))
 
         # Make sure the values are the same at the point of linking.
@@ -2201,7 +2201,7 @@ class TestDirectionalLink(TestCase):
         a = A(value=9)
         b = A(value=8)
 
-        # Conenct the two classes.
+        # Connect the two classes.
         c = directional_link((a, "value"), (b, "value"), lambda x: 2 * x)
 
         # Make sure the values are correct at the point of linking.
@@ -2227,7 +2227,7 @@ class TestDirectionalLink(TestCase):
         a = A(value=9)
         b = B(count=8)
 
-        # Conenct the two classes.
+        # Connect the two classes.
         c = directional_link((a, "value"), (b, "count"))
 
         # Make sure the values are the same at the point of linking.

+ 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.11.2"
+__version__ = "5.12.0"
 
 # Build up version_info tuple for backwards compatibility
 pattern = r"(?P<major>\d+).(?P<minor>\d+).(?P<patch>\d+)(?P<rest>.*)"

+ 16 - 16
contrib/python/traitlets/py3/traitlets/config/application.py

@@ -298,7 +298,7 @@ class Application(SingletonConfigurable):
         log = logging.getLogger(self.__class__.__name__)
         log.propagate = False
         _log = log  # copied from Logger.hasHandlers() (new in Python 3.2)
-        while _log:
+        while _log is not None:
             if _log.handlers:
                 return log
             if not _log.propagate:
@@ -337,21 +337,21 @@ class Application(SingletonConfigurable):
             .. code-block:: python
 
                c.Application.logging_config = {
-                   'handlers': {
-                       'file': {
-                           'class': 'logging.FileHandler',
-                           'level': 'DEBUG',
-                           'filename': '<path/to/file>',
+                   "handlers": {
+                       "file": {
+                           "class": "logging.FileHandler",
+                           "level": "DEBUG",
+                           "filename": "<path/to/file>",
                        }
                    },
-                   'loggers': {
-                       '<application-name>': {
-                           'level': 'DEBUG',
+                   "loggers": {
+                       "<application-name>": {
+                           "level": "DEBUG",
                            # NOTE: if you don't list the default "console"
                            # handler here then it will be disabled
-                           'handlers': ['console', 'file'],
+                           "handlers": ["console", "file"],
                        },
-                   }
+                   },
                }
 
         """,
@@ -535,7 +535,7 @@ class Application(SingletonConfigurable):
                 trait = cls.class_traits(config=True)[traitname]
                 fhelp_lines = cls.class_get_trait_help(trait, helptext=fhelp).splitlines()
 
-                if not isinstance(alias, tuple):
+                if not isinstance(alias, tuple):  # type:ignore[unreachable]
                     alias = (alias,)  # type:ignore[assignment]
                 alias = sorted(alias, key=len)  # type:ignore[assignment]
                 alias = ", ".join(("--%s" if len(m) > 1 else "-%s") % m for m in alias)
@@ -559,7 +559,7 @@ class Application(SingletonConfigurable):
 
         for flags, (cfg, fhelp) in self.flags.items():
             try:
-                if not isinstance(flags, tuple):
+                if not isinstance(flags, tuple):  # type:ignore[unreachable]
                     flags = (flags,)  # type:ignore[assignment]
                 flags = sorted(flags, key=len)  # type:ignore[assignment]
                 flags = ", ".join(("--%s" if len(m) > 1 else "-%s") % m for m in flags)
@@ -643,7 +643,7 @@ class Application(SingletonConfigurable):
 
         if classes:
             help_classes = self._classes_with_config_traits()
-            if help_classes:
+            if help_classes is not None:
                 yield "Class options"
                 yield "============="
                 for p in wrap_paragraphs(self.keyvalue_description):
@@ -752,7 +752,7 @@ class Application(SingletonConfigurable):
             if len(children) == 1:
                 # exactly one descendent, promote alias
                 cls = children[0]  # type:ignore[assignment]
-            if not isinstance(aliases, tuple):
+            if not isinstance(aliases, tuple):  # type:ignore[unreachable]
                 alias = (alias,)  # type:ignore[assignment]
             for al in alias:
                 aliases[al] = ".".join([cls, trait])  # type:ignore[list-item]
@@ -773,7 +773,7 @@ class Application(SingletonConfigurable):
                 else:
                     newflag[cls] = subdict
 
-            if not isinstance(key, tuple):
+            if not isinstance(key, tuple):  # type:ignore[unreachable]
                 key = (key,)  # type:ignore[assignment]
             for k in key:
                 flags[k] = (newflag, help)

+ 9 - 13
contrib/python/traitlets/py3/traitlets/config/argcomplete_config.py

@@ -10,7 +10,7 @@ import typing as t
 
 try:
     import argcomplete
-    from argcomplete import CompletionFinder  # type:ignore
+    from argcomplete import CompletionFinder
 except ImportError:
     # This module and its utility methods are written to not crash even
     # if argcomplete is not installed.
@@ -20,8 +20,8 @@ except ImportError:
                 raise ModuleNotFoundError("No module named 'argcomplete'")
             raise AttributeError(f"argcomplete stub module has no attribute '{attr}'")
 
-    argcomplete = StubModule()  # type:ignore
-    CompletionFinder = object  # type:ignore
+    argcomplete = StubModule()  # type:ignore[assignment]
+    CompletionFinder = object  # type:ignore[assignment, misc]
 
 
 def get_argcomplete_cwords() -> t.Optional[t.List[str]]:
@@ -45,9 +45,7 @@ def get_argcomplete_cwords() -> t.Optional[t.List[str]]:
             cword_suffix,
             comp_words,
             last_wordbreak_pos,
-        ) = argcomplete.split_line(  # type:ignore
-            comp_line, comp_point
-        )
+        ) = argcomplete.split_line(comp_line, comp_point)
     except ModuleNotFoundError:
         return None
 
@@ -75,9 +73,7 @@ def increment_argcomplete_index() -> None:
         os.environ["_ARGCOMPLETE"] = str(int(os.environ["_ARGCOMPLETE"]) + 1)
     except Exception:
         try:
-            argcomplete.debug(  # type:ignore
-                "Unable to increment $_ARGCOMPLETE", os.environ["_ARGCOMPLETE"]
-            )
+            argcomplete.debug("Unable to increment $_ARGCOMPLETE", os.environ["_ARGCOMPLETE"])
         except (KeyError, ModuleNotFoundError):
             pass
 
@@ -153,7 +149,7 @@ class ExtendedCompletionFinder(CompletionFinder):
     def _get_completions(
         self, comp_words: t.List[str], cword_prefix: str, *args: t.Any
     ) -> t.List[str]:
-        """Overriden to dynamically append --Class.trait arguments if appropriate
+        """Overridden to dynamically append --Class.trait arguments if appropriate
 
         Warning:
             This does not (currently) support completions of the form
@@ -200,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
+            argcomplete.debug("Adding subcommands for", cword_prefix)
             completions.extend(subc for subc in self.subcommands if subc.startswith(cword_prefix))
 
         return completions
@@ -208,7 +204,7 @@ class ExtendedCompletionFinder(CompletionFinder):
     def _get_option_completions(
         self, parser: argparse.ArgumentParser, cword_prefix: str
     ) -> t.List[str]:
-        """Overriden to add --Class. completions when appropriate"""
+        """Overridden to add --Class. completions when appropriate"""
         completions: t.List[str]
         completions = super()._get_option_completions(parser, cword_prefix)
         if cword_prefix.endswith("."):
@@ -217,7 +213,7 @@ class ExtendedCompletionFinder(CompletionFinder):
         matched_completions = self.match_class_completions(cword_prefix)
         if len(matched_completions) > 1:
             completions.extend(opt for cls, opt in matched_completions)
-        # If there is exactly one match, we would expect it to have aleady
+        # If there is exactly one match, we would expect it to have already
         # been handled by the options dynamically added in _get_completions().
         # However, maybe there's an edge cases missed here, for example if the
         # matched class has no configurable traits.

+ 13 - 7
contrib/python/traitlets/py3/traitlets/config/configurable.py

@@ -123,7 +123,7 @@ class Configurable(HasTraits):
             setattr(self, name, kwargs[name])
 
     # -------------------------------------------------------------------------
-    # Static trait notifiations
+    # Static trait notifications
     # -------------------------------------------------------------------------
 
     @classmethod
@@ -161,7 +161,10 @@ class Configurable(HasTraits):
         return my_config
 
     def _load_config(
-        self, cfg: Config, section_names: list[str] | None = None, traits: list[str] | None = None
+        self,
+        cfg: Config,
+        section_names: list[str] | None = None,
+        traits: dict[str, TraitType] | None = None,
     ) -> None:
         """load traits from a Config object"""
 
@@ -344,6 +347,7 @@ class Configurable(HasTraits):
             if the defining class is not in `classes`.
         """
         defining_cls = cls
+        assert trait.name is not None
         for parent in cls.mro():
             if (
                 issubclass(parent, Configurable)
@@ -382,9 +386,9 @@ class Configurable(HasTraits):
             desc = desc.default_value
         if not desc:
             # no description from trait, use __doc__
-            desc = getattr(cls, "__doc__", "")
+            desc = getattr(cls, "__doc__", "")  # type:ignore[arg-type]
         if desc:
-            lines.append(c(desc))
+            lines.append(c(desc))  # type:ignore[arg-type]
             lines.append("")
 
         for name, trait in sorted(cls.class_traits(config=True).items()):
@@ -424,12 +428,14 @@ class Configurable(HasTraits):
         for _, trait in sorted(cls.class_traits(config=True).items()):
             ttype = trait.__class__.__name__
 
+            if not trait.name:
+                continue
             termline = classname + "." + trait.name
 
             # Choices or type
             if "Enum" in ttype:
                 # include Enum choices
-                termline += " : " + trait.info_rst()
+                termline += " : " + trait.info_rst()  # type:ignore[attr-defined]
             else:
                 termline += " : " + ttype
             lines.append(termline)
@@ -540,7 +546,7 @@ class SingletonConfigurable(LoggingConfigurable):
             if isinstance(subclass._instance, cls):
                 # only clear instances that are instances
                 # of the calling class
-                subclass._instance = None
+                subclass._instance = None  # type:ignore[unreachable]
 
     @classmethod
     def instance(cls: type[CT], *args: t.Any, **kwargs: t.Any) -> CT:
@@ -562,7 +568,7 @@ class SingletonConfigurable(LoggingConfigurable):
             >>> foo == Foo.instance()
             True
 
-        Create a subclass that is retrived using the base class instance::
+        Create a subclass that is retrieved using the base class instance::
 
             >>> class Bar(SingletonConfigurable): pass
             >>> class Bam(Bar): pass

+ 6 - 4
contrib/python/traitlets/py3/traitlets/config/loader.py

@@ -176,7 +176,7 @@ class LazyConfigValue(HasTraits):
         after applying any insert / extend / update changes
         """
         if self._value is not None:
-            return self._value
+            return self._value  # type:ignore[unreachable]
         value = copy.deepcopy(initial)
         if isinstance(value, list):
             for idx, obj in self._inserts:
@@ -860,7 +860,7 @@ class ArgParseConfigLoader(CommandLineConfigLoader):
             arguments from. If not given, the instance's self.argv attribute
             (given at construction time) is used.
         flags
-            Deprecated in traitlets 5.0, instanciate the config loader with the flags.
+            Deprecated in traitlets 5.0, instantiate the config loader with the flags.
 
         """
 
@@ -914,7 +914,7 @@ class ArgParseConfigLoader(CommandLineConfigLoader):
             for alias, alias_target in self.aliases.items():
                 if alias in self.flags:
                     continue
-                if not isinstance(alias, tuple):
+                if not isinstance(alias, tuple):  # type:ignore[unreachable]
                     alias = (alias,)  # type:ignore[assignment]
                 for al in alias:
                     if len(al) == 1:
@@ -1057,7 +1057,9 @@ class KVArgParseConfigLoader(ArgParseConfigLoader):
                 action = paa(*keys, **argparse_kwds)
                 if argcompleter is not None:
                     # argcomplete's completers are callables returning list of completion strings
-                    action.completer = functools.partial(argcompleter, key=key)  # type: ignore
+                    action.completer = functools.partial(  # type:ignore[attr-defined]
+                        argcompleter, key=key
+                    )
 
     def _convert_to_config(self):
         """self.parsed_data->self.config, parse unrecognized extra args via KVLoader."""

Some files were not shown because too many files changed in this diff