aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/traitlets
diff options
context:
space:
mode:
authorarmenqa <armenqa@yandex-team.com>2024-01-19 12:23:50 +0300
committerarmenqa <armenqa@yandex-team.com>2024-01-19 13:10:03 +0300
commit2de0149d0151c514b22bca0760b95b26c9b0b578 (patch)
tree2bfed9f3bce7e643ddf048bb61ce3dc0a714bcc2 /contrib/python/traitlets
parenta8c06d218f12b2406fbce24d194885c5d7b68503 (diff)
downloadydb-2de0149d0151c514b22bca0760b95b26c9b0b578.tar.gz
feat contrib: aiogram 3
Relates: https://st.yandex-team.ru/, https://st.yandex-team.ru/
Diffstat (limited to 'contrib/python/traitlets')
-rw-r--r--contrib/python/traitlets/py3/.dist-info/METADATA2
-rw-r--r--contrib/python/traitlets/py3/tests/_warnings.py1
-rw-r--r--contrib/python/traitlets/py3/tests/config/test_application.py10
-rw-r--r--contrib/python/traitlets/py3/tests/config/test_argcomplete.py8
-rw-r--r--contrib/python/traitlets/py3/tests/config/test_configurable.py5
-rw-r--r--contrib/python/traitlets/py3/tests/config/test_loader.py6
-rw-r--r--contrib/python/traitlets/py3/tests/test_traitlets.py19
-rw-r--r--contrib/python/traitlets/py3/tests/test_traitlets_docstring.py2
-rw-r--r--contrib/python/traitlets/py3/tests/test_traitlets_enum.py3
-rw-r--r--contrib/python/traitlets/py3/tests/utils/test_bunch.py2
-rw-r--r--contrib/python/traitlets/py3/tests/utils/test_decorators.py2
-rw-r--r--contrib/python/traitlets/py3/tests/utils/test_importstring.py1
-rw-r--r--contrib/python/traitlets/py3/traitlets/__init__.py2
-rw-r--r--contrib/python/traitlets/py3/traitlets/_version.py4
-rw-r--r--contrib/python/traitlets/py3/traitlets/config/__init__.py4
-rw-r--r--contrib/python/traitlets/py3/traitlets/config/application.py14
-rw-r--r--contrib/python/traitlets/py3/traitlets/config/argcomplete_config.py4
-rw-r--r--contrib/python/traitlets/py3/traitlets/config/configurable.py2
-rw-r--r--contrib/python/traitlets/py3/traitlets/config/loader.py24
-rw-r--r--contrib/python/traitlets/py3/traitlets/config/manager.py3
-rw-r--r--contrib/python/traitlets/py3/traitlets/config/sphinxdoc.py3
-rw-r--r--contrib/python/traitlets/py3/traitlets/log.py2
-rw-r--r--contrib/python/traitlets/py3/traitlets/tests/utils.py2
-rw-r--r--contrib/python/traitlets/py3/traitlets/traitlets.py62
-rw-r--r--contrib/python/traitlets/py3/traitlets/utils/decorators.py1
-rw-r--r--contrib/python/traitlets/py3/traitlets/utils/descriptions.py3
-rw-r--r--contrib/python/traitlets/py3/traitlets/utils/getargspec.py2
-rw-r--r--contrib/python/traitlets/py3/traitlets/utils/importstring.py2
-rw-r--r--contrib/python/traitlets/py3/traitlets/utils/nested_update.py2
-rw-r--r--contrib/python/traitlets/py3/traitlets/utils/text.py4
-rw-r--r--contrib/python/traitlets/py3/ya.make2
31 files changed, 105 insertions, 98 deletions
diff --git a/contrib/python/traitlets/py3/.dist-info/METADATA b/contrib/python/traitlets/py3/.dist-info/METADATA
index 527825535a..5e9a9e1518 100644
--- a/contrib/python/traitlets/py3/.dist-info/METADATA
+++ b/contrib/python/traitlets/py3/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: traitlets
-Version: 5.14.0
+Version: 5.14.1
Summary: Traitlets Python configuration system
Project-URL: Homepage, https://github.com/ipython/traitlets
Project-URL: Documentation, https://traitlets.readthedocs.io
diff --git a/contrib/python/traitlets/py3/tests/_warnings.py b/contrib/python/traitlets/py3/tests/_warnings.py
index 1fb6e9a9a5..3447fbef8a 100644
--- a/contrib/python/traitlets/py3/tests/_warnings.py
+++ b/contrib/python/traitlets/py3/tests/_warnings.py
@@ -1,5 +1,6 @@
# From scikit-image: https://github.com/scikit-image/scikit-image/blob/c2f8c4ab123ebe5f7b827bc495625a32bb225c10/skimage/_shared/_warnings.py
# Licensed under modified BSD license
+from __future__ import annotations
__all__ = ["all_warnings", "expected_warnings"]
diff --git a/contrib/python/traitlets/py3/tests/config/test_application.py b/contrib/python/traitlets/py3/tests/config/test_application.py
index 61ad751c6b..73d31432a4 100644
--- a/contrib/python/traitlets/py3/tests/config/test_application.py
+++ b/contrib/python/traitlets/py3/tests/config/test_application.py
@@ -4,6 +4,7 @@ Tests for traitlets.config.application.Application
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
+from __future__ import annotations
import contextlib
import io
@@ -17,7 +18,6 @@ from tempfile import TemporaryDirectory
from unittest import TestCase, mock
import pytest
-from pytest import mark
from traitlets import Bool, Bytes, Dict, HasTraits, Integer, List, Set, Tuple, Unicode
from traitlets.config.application import Application
@@ -551,7 +551,7 @@ class TestApplication(TestCase):
app.init_bar()
self.assertEqual(app.bar.b, 1)
- @mark.skipif(not hasattr(TestCase, "assertLogs"), reason="requires TestCase.assertLogs")
+ @pytest.mark.skipif(not hasattr(TestCase, "assertLogs"), reason="requires TestCase.assertLogs")
def test_log_collisions(self):
app = MyApp()
app.log = logging.getLogger()
@@ -572,7 +572,7 @@ class TestApplication(TestCase):
assert pjoin(td, name + ".py") in output
assert pjoin(td, name + ".json") in output
- @mark.skipif(not hasattr(TestCase, "assertLogs"), reason="requires TestCase.assertLogs")
+ @pytest.mark.skipif(not hasattr(TestCase, "assertLogs"), reason="requires TestCase.assertLogs")
def test_log_bad_config(self):
app = MyApp()
app.log = logging.getLogger()
@@ -670,7 +670,7 @@ class TestApplication(TestCase):
self.assertEqual(app.running, False)
-@mark.skip
+@pytest.mark.skip
def test_cli_multi_scalar(caplog):
class App(Application):
aliases = {"opt": "App.opt"}
@@ -855,7 +855,7 @@ def test_get_default_logging_config_pythonw(monkeypatch):
assert "loggers" in config
-@pytest.fixture
+@pytest.fixture()
def caplogconfig(monkeypatch):
"""Capture logging config events for DictConfigurator objects.
diff --git a/contrib/python/traitlets/py3/tests/config/test_argcomplete.py b/contrib/python/traitlets/py3/tests/config/test_argcomplete.py
index 0cd992c612..3f1ce482e8 100644
--- a/contrib/python/traitlets/py3/tests/config/test_argcomplete.py
+++ b/contrib/python/traitlets/py3/tests/config/test_argcomplete.py
@@ -4,6 +4,7 @@ Tests for argcomplete handling by traitlets.config.application.Application
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
+from __future__ import annotations
import io
import os
@@ -71,7 +72,7 @@ class TestArgcomplete:
IFS = "\013"
COMP_WORDBREAKS = " \t\n\"'><=;|&(:"
- @pytest.fixture
+ @pytest.fixture()
def argcomplete_on(self, mocker):
"""Mostly borrowed from argcomplete's unit test fixtures
@@ -119,7 +120,7 @@ class TestArgcomplete:
os.environ["COMP_LINE"] = command
os.environ["COMP_POINT"] = str(point)
- with pytest.raises(CustomError) as cm:
+ with pytest.raises(CustomError) as cm: # noqa: PT012
app.argcomplete_kwargs = dict(
output_stream=strio, exit_method=CustomError.exit, **kwargs
)
@@ -216,4 +217,5 @@ class TestArgcomplete:
app = MainApp()
completions = set(self.run_completer(app, "app --"))
assert completions > {"--Application.", "--MainApp."}
- assert "--SubApp1." not in completions and "--SubApp2." not in completions
+ assert "--SubApp1." not in completions
+ assert "--SubApp2." not in completions
diff --git a/contrib/python/traitlets/py3/tests/config/test_configurable.py b/contrib/python/traitlets/py3/tests/config/test_configurable.py
index f6499ea29d..f1e8ed74a3 100644
--- a/contrib/python/traitlets/py3/tests/config/test_configurable.py
+++ b/contrib/python/traitlets/py3/tests/config/test_configurable.py
@@ -2,11 +2,12 @@
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
+from __future__ import annotations
import logging
from unittest import TestCase
-from pytest import mark
+import pytest
from .._warnings import expected_warnings
from traitlets.config.application import Application
@@ -672,7 +673,7 @@ class TestLogger(TestCase):
bar = Integer(config=True)
baz = Integer(config=True)
- @mark.skipif(not hasattr(TestCase, "assertLogs"), reason="requires TestCase.assertLogs")
+ @pytest.mark.skipif(not hasattr(TestCase, "assertLogs"), reason="requires TestCase.assertLogs")
def test_warn_match(self):
logger = logging.getLogger("test_warn_match")
cfg = Config({"A": {"bat": 5}})
diff --git a/contrib/python/traitlets/py3/tests/config/test_loader.py b/contrib/python/traitlets/py3/tests/config/test_loader.py
index 9d864317bc..6e1510c2cd 100644
--- a/contrib/python/traitlets/py3/tests/config/test_loader.py
+++ b/contrib/python/traitlets/py3/tests/config/test_loader.py
@@ -2,6 +2,7 @@
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
+from __future__ import annotations
import copy
import os
@@ -123,9 +124,8 @@ class TestFileCL(TestCase):
with JSONFileConfigLoader(fname, log=log) as config:
config.A.b = 1
- with self.assertRaises(TypeError):
- with JSONFileConfigLoader(fname, log=log) as config:
- config.A.cant_json = lambda x: x
+ with self.assertRaises(TypeError), JSONFileConfigLoader(fname, log=log) as config:
+ config.A.cant_json = lambda x: x
loader = JSONFileConfigLoader(fname, log=log)
cfg = loader.load_config()
diff --git a/contrib/python/traitlets/py3/tests/test_traitlets.py b/contrib/python/traitlets/py3/tests/test_traitlets.py
index 07c95ca251..dfcf3f0f4b 100644
--- a/contrib/python/traitlets/py3/tests/test_traitlets.py
+++ b/contrib/python/traitlets/py3/tests/test_traitlets.py
@@ -5,6 +5,7 @@
#
# Adapted from enthought.traits, Copyright (c) Enthought, Inc.,
# also under the terms of the Modified BSD License.
+from __future__ import annotations
import pickle
import re
@@ -1254,7 +1255,7 @@ class TraitTestBase(TestCase):
try:
self.assertRaises(TraitError, self.assign, value)
except AssertionError:
- assert False, value
+ assert False, value # noqa: PT015
def test_default_value(self):
if hasattr(self, "_default_value"):
@@ -1784,7 +1785,7 @@ class TestMultiTuple(TraitTestBase):
@pytest.mark.parametrize(
"Trait",
- (
+ ( # noqa: PT007
List,
Tuple,
Set,
@@ -1808,7 +1809,7 @@ def test_allow_none_default_value(Trait):
@pytest.mark.parametrize(
"Trait, default_value",
- ((List, []), (Tuple, ()), (Set, set()), (Dict, {}), (Integer, 0), (Unicode, "")),
+ ((List, []), (Tuple, ()), (Set, set()), (Dict, {}), (Integer, 0), (Unicode, "")), # noqa: PT007
)
def test_default_value(Trait, default_value):
class C(HasTraits):
@@ -1822,7 +1823,7 @@ def test_default_value(Trait, default_value):
@pytest.mark.parametrize(
"Trait, default_value",
- ((List, []), (Tuple, ()), (Set, set())),
+ ((List, []), (Tuple, ()), (Set, set())), # noqa: PT007
)
def test_subclass_default_value(Trait, default_value):
"""Test deprecated default_value=None behavior for Container subclass traits"""
@@ -2150,7 +2151,7 @@ class TestLink(TestCase):
self.i = change.new * 2
mc = MyClass()
- l = link((mc, "i"), (mc, "j")) # noqa
+ l = link((mc, "i"), (mc, "j")) # noqa: E741
self.assertRaises(TraitError, setattr, mc, "i", 2)
def test_link_broken_at_target(self):
@@ -2163,7 +2164,7 @@ class TestLink(TestCase):
self.j = change.new * 2
mc = MyClass()
- l = link((mc, "i"), (mc, "j")) # noqa
+ l = link((mc, "i"), (mc, "j")) # noqa: E741
self.assertRaises(TraitError, setattr, mc, "j", 2)
@@ -2393,7 +2394,7 @@ class OrderTraits(HasTraits):
i = Unicode()
j = Unicode()
k = Unicode()
- l = Unicode() # noqa
+ l = Unicode() # noqa: E741
def _notify(self, name, old, new):
"""check the value of all traits when each trait change is triggered
@@ -2819,7 +2820,7 @@ def test_default_mro():
def test_cls_self_argument():
class X(HasTraits):
- def __init__(__self, cls, self): # noqa
+ def __init__(__self, cls, self):
pass
x = X(cls=None, self=None)
@@ -2889,7 +2890,7 @@ def _from_string_test(traittype, s, expected):
else:
cast = trait.from_string
if type(expected) is type and issubclass(expected, Exception):
- with pytest.raises(expected):
+ with pytest.raises(expected): # noqa: PT012
value = cast(s)
trait.validate(CrossValidationStub(), value) # type:ignore
else:
diff --git a/contrib/python/traitlets/py3/tests/test_traitlets_docstring.py b/contrib/python/traitlets/py3/tests/test_traitlets_docstring.py
index 700199108f..685ea71f69 100644
--- a/contrib/python/traitlets/py3/tests/test_traitlets_docstring.py
+++ b/contrib/python/traitlets/py3/tests/test_traitlets_docstring.py
@@ -3,6 +3,8 @@
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
#
+from __future__ import annotations
+
from traitlets import Dict, Instance, Integer, Unicode, Union
from traitlets.config import Configurable
diff --git a/contrib/python/traitlets/py3/tests/test_traitlets_enum.py b/contrib/python/traitlets/py3/tests/test_traitlets_enum.py
index c39007e8a0..ac19e9d519 100644
--- a/contrib/python/traitlets/py3/tests/test_traitlets_enum.py
+++ b/contrib/python/traitlets/py3/tests/test_traitlets_enum.py
@@ -2,6 +2,7 @@
"""
Test the trait-type ``UseEnum``.
"""
+from __future__ import annotations
import enum
import unittest
@@ -280,7 +281,7 @@ class TestFuzzyEnum(unittest.TestCase):
example = FuzzyExample()
for color in color_choices:
- for wlen in range(0, 2):
+ for wlen in range(2):
value = color[wlen:]
example.color = value
diff --git a/contrib/python/traitlets/py3/tests/utils/test_bunch.py b/contrib/python/traitlets/py3/tests/utils/test_bunch.py
index 223124d7d5..90efe98273 100644
--- a/contrib/python/traitlets/py3/tests/utils/test_bunch.py
+++ b/contrib/python/traitlets/py3/tests/utils/test_bunch.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
from traitlets.utils.bunch import Bunch
diff --git a/contrib/python/traitlets/py3/tests/utils/test_decorators.py b/contrib/python/traitlets/py3/tests/utils/test_decorators.py
index d6bf8414e5..39b882c0ea 100644
--- a/contrib/python/traitlets/py3/tests/utils/test_decorators.py
+++ b/contrib/python/traitlets/py3/tests/utils/test_decorators.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
from inspect import Parameter, signature
from unittest import TestCase
diff --git a/contrib/python/traitlets/py3/tests/utils/test_importstring.py b/contrib/python/traitlets/py3/tests/utils/test_importstring.py
index 8ce28add41..43fcdaaff2 100644
--- a/contrib/python/traitlets/py3/tests/utils/test_importstring.py
+++ b/contrib/python/traitlets/py3/tests/utils/test_importstring.py
@@ -4,6 +4,7 @@
# Adapted from enthought.traits, Copyright (c) Enthought, Inc.,
# also under the terms of the Modified BSD License.
"""Tests for traitlets.utils.importstring."""
+from __future__ import annotations
import os
from unittest import TestCase
diff --git a/contrib/python/traitlets/py3/traitlets/__init__.py b/contrib/python/traitlets/py3/traitlets/__init__.py
index 70ed818aca..e27ecf1a45 100644
--- a/contrib/python/traitlets/py3/traitlets/__init__.py
+++ b/contrib/python/traitlets/py3/traitlets/__init__.py
@@ -1,4 +1,6 @@
"""Traitlets Python configuration system"""
+from __future__ import annotations
+
import typing as _t
from . import traitlets
diff --git a/contrib/python/traitlets/py3/traitlets/_version.py b/contrib/python/traitlets/py3/traitlets/_version.py
index 7a5c6e1005..08221fa99f 100644
--- a/contrib/python/traitlets/py3/traitlets/_version.py
+++ b/contrib/python/traitlets/py3/traitlets/_version.py
@@ -1,11 +1,13 @@
"""
handle the current version info of traitlets.
"""
+from __future__ import annotations
+
import re
from typing import List
# Version string must appear intact for hatch versioning
-__version__ = "5.14.0"
+__version__ = "5.14.1"
# Build up version_info tuple for backwards compatibility
pattern = r"(?P<major>\d+).(?P<minor>\d+).(?P<patch>\d+)(?P<rest>.*)"
diff --git a/contrib/python/traitlets/py3/traitlets/config/__init__.py b/contrib/python/traitlets/py3/traitlets/config/__init__.py
index 699b12b80a..e51a4219a0 100644
--- a/contrib/python/traitlets/py3/traitlets/config/__init__.py
+++ b/contrib/python/traitlets/py3/traitlets/config/__init__.py
@@ -1,16 +1,18 @@
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
+from __future__ import annotations
from .application import *
from .configurable import *
from .loader import Config
-__all__ = [ # noqa
+__all__ = [ # noqa: F405
"Config",
"Application",
"ApplicationError",
"LevelFormatter",
"configurable",
+ "Configurable",
"ConfigurableError",
"MultipleInstanceError",
"LoggingConfigurable",
diff --git a/contrib/python/traitlets/py3/traitlets/config/application.py b/contrib/python/traitlets/py3/traitlets/config/application.py
index 9a3fcc949e..b01a11e518 100644
--- a/contrib/python/traitlets/py3/traitlets/config/application.py
+++ b/contrib/python/traitlets/py3/traitlets/config/application.py
@@ -304,8 +304,7 @@ class Application(SingletonConfigurable):
return log
if not _log.propagate:
break
- else:
- _log = _log.parent # type:ignore[assignment]
+ _log = _log.parent # type:ignore[assignment]
return log
logging_config = Dict(
@@ -501,7 +500,7 @@ class Application(SingletonConfigurable):
if not class_config:
continue
print(classname)
- pformat_kwargs: StrDict = dict(indent=4, compact=True)
+ pformat_kwargs: StrDict = dict(indent=4, compact=True) # noqa: C408
for traitname in sorted(class_config):
value = class_config[traitname]
@@ -924,7 +923,7 @@ class Application(SingletonConfigurable):
if raise_config_file_errors:
raise
if log:
- log.error("Exception while loading config file %s", filename, exc_info=True)
+ log.error("Exception while loading config file %s", filename, exc_info=True) # noqa: G201
else:
if log:
log.debug("Loaded config file: %s", loader.full_filename)
@@ -933,7 +932,7 @@ class Application(SingletonConfigurable):
collisions = earlier_config.collisions(config)
if collisions and log:
log.warning(
- "Collisions detected in {0} and {1} config files."
+ "Collisions detected in {0} and {1} config files." # noqa: G001
" {1} has higher priority: {2}".format(
filename,
loader.full_filename,
@@ -974,8 +973,7 @@ class Application(SingletonConfigurable):
@catch_config_error
def load_config_environ(self) -> None:
"""Load config files by environment."""
-
- PREFIX = self.name.upper()
+ PREFIX = self.name.upper().replace("-", "_")
new_config = Config()
self.log.debug('Looping through config variables with prefix "%s"', PREFIX)
@@ -1059,7 +1057,7 @@ class Application(SingletonConfigurable):
self._logging_configured = False
def exit(self, exit_status: int | str | None = 0) -> None:
- self.log.debug("Exiting application: %s" % self.name)
+ self.log.debug("Exiting application: %s", self.name)
self.close_handlers()
sys.exit(exit_status)
diff --git a/contrib/python/traitlets/py3/traitlets/config/argcomplete_config.py b/contrib/python/traitlets/py3/traitlets/config/argcomplete_config.py
index 6c04fd5675..1f4cf1c787 100644
--- a/contrib/python/traitlets/py3/traitlets/config/argcomplete_config.py
+++ b/contrib/python/traitlets/py3/traitlets/config/argcomplete_config.py
@@ -2,7 +2,7 @@
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
-
+from __future__ import annotations
import argparse
import os
@@ -58,7 +58,7 @@ def get_argcomplete_cwords() -> t.Optional[t.List[str]]:
comp_words = comp_words[start:]
# argcomplete.debug("prequote=", cword_prequote, "prefix=", cword_prefix, "suffix=", cword_suffix, "words=", comp_words, "last=", last_wordbreak_pos)
- return comp_words
+ return comp_words # noqa: RET504
def increment_argcomplete_index() -> None:
diff --git a/contrib/python/traitlets/py3/traitlets/config/configurable.py b/contrib/python/traitlets/py3/traitlets/config/configurable.py
index 3e8c868ce0..44b4793ebd 100644
--- a/contrib/python/traitlets/py3/traitlets/config/configurable.py
+++ b/contrib/python/traitlets/py3/traitlets/config/configurable.py
@@ -324,7 +324,7 @@ class Configurable(HasTraits):
@classmethod
def class_print_help(cls, inst: HasTraits | None = None) -> None:
"""Get the help string for a single trait and print it."""
- print(cls.class_get_help(inst))
+ print(cls.class_get_help(inst)) # noqa: T201
@classmethod
def _defining_class(
diff --git a/contrib/python/traitlets/py3/traitlets/config/loader.py b/contrib/python/traitlets/py3/traitlets/config/loader.py
index 2b0932a98e..f9eb5fe191 100644
--- a/contrib/python/traitlets/py3/traitlets/config/loader.py
+++ b/contrib/python/traitlets/py3/traitlets/config/loader.py
@@ -31,7 +31,7 @@ class ConfigLoaderError(ConfigError):
pass
-class ConfigFileNotFound(ConfigError): # noqa
+class ConfigFileNotFound(ConfigError):
pass
@@ -79,7 +79,7 @@ class ArgumentParser(argparse.ArgumentParser):
def execfile(fname: str, glob: dict[str, Any]) -> None:
with open(fname, "rb") as f:
- exec(compile(f.read(), fname, "exec"), glob, glob) # noqa
+ exec(compile(f.read(), fname, "exec"), glob, glob) # noqa: S102
class LazyConfigValue(HasTraits):
@@ -218,10 +218,7 @@ class LazyConfigValue(HasTraits):
def _is_section_key(key: str) -> bool:
"""Is a Config key a section name (does it start with a capital)?"""
- if key and key[0].upper() == key[0] and not key.startswith("_"):
- return True
- else:
- return False
+ return bool(key and key[0].upper() == key[0] and not key.startswith("_"))
class Config(dict): # type:ignore[type-arg]
@@ -382,8 +379,6 @@ class Config(dict): # type:ignore[type-arg]
class DeferredConfig:
"""Class for deferred-evaluation of config from CLI"""
- pass
-
def get_value(self, trait: TraitType[t.Any, t.Any]) -> t.Any:
raise NotImplementedError("Implement in subclasses")
@@ -597,7 +592,7 @@ class JSONFileConfigLoader(FileConfigLoader):
self.load_config()
return self.config
- def __exit__(self, exc_type: t.Any, exc_value: t.Any, traceback: t.Any) -> None:
+ def __exit__(self, exc_type: object, exc_value: object, traceback: object) -> None:
"""
Exit the context manager but do not handle any errors.
@@ -649,7 +644,7 @@ class PyFileConfigLoader(FileConfigLoader):
"""Unnecessary now, but a deprecation warning is more trouble than it's worth."""
return self.config
- namespace = dict(
+ namespace = dict( # noqa: C408
c=self.config,
load_subconfig=self.load_subconfig,
get_config=get_config,
@@ -657,7 +652,7 @@ class PyFileConfigLoader(FileConfigLoader):
)
conf_filename = self.full_filename
with open(conf_filename, "rb") as f:
- exec(compile(f.read(), conf_filename, "exec"), namespace, namespace) # noqa
+ exec(compile(f.read(), conf_filename, "exec"), namespace, namespace) # noqa: S102
class CommandLineConfigLoader(ConfigLoader):
@@ -856,7 +851,7 @@ class ArgParseConfigLoader(CommandLineConfigLoader):
self.parser_args = parser_args
self.version = parser_kw.pop("version", None)
- kwargs = dict(argument_default=argparse.SUPPRESS)
+ kwargs = dict(argument_default=argparse.SUPPRESS) # noqa: C408
kwargs.update(parser_kw)
self.parser_kw = kwargs
@@ -919,7 +914,6 @@ class ArgParseConfigLoader(CommandLineConfigLoader):
def _argcomplete(self, classes: list[t.Any], subcommands: SubcommandsDict | None) -> None:
"""If argcomplete is enabled, allow triggering command-line autocompletion"""
- pass
def _parse_args(self, args: t.Any) -> t.Any:
"""self.parser->self.parsed_data"""
@@ -1089,7 +1083,7 @@ class KVArgParseConfigLoader(ArgParseConfigLoader):
if lhs == "extra_args":
self.extra_args = ["-" if a == _DASH_REPLACEMENT else a for a in rhs] + extra_args
continue
- elif lhs == "_flags":
+ if lhs == "_flags":
# _flags will be handled later
continue
@@ -1132,7 +1126,7 @@ class KVArgParseConfigLoader(ArgParseConfigLoader):
def _argcomplete(self, classes: list[t.Any], subcommands: SubcommandsDict | None) -> None:
"""If argcomplete is enabled, allow triggering command-line autocompletion"""
try:
- import argcomplete # noqa
+ import argcomplete # noqa: F401
except ImportError:
return
diff --git a/contrib/python/traitlets/py3/traitlets/config/manager.py b/contrib/python/traitlets/py3/traitlets/config/manager.py
index 9102544e50..f87b21e782 100644
--- a/contrib/python/traitlets/py3/traitlets/config/manager.py
+++ b/contrib/python/traitlets/py3/traitlets/config/manager.py
@@ -70,8 +70,7 @@ class BaseJSONConfigManager(LoggingConfigurable):
filename = self.file_name(section_name)
self.ensure_config_dir_exists()
- f = open(filename, "w", encoding="utf-8")
- with f:
+ with open(filename, "w", encoding="utf-8") as f:
json.dump(data, f, indent=2)
def update(self, section_name: str, new_data: Any) -> Any:
diff --git a/contrib/python/traitlets/py3/traitlets/config/sphinxdoc.py b/contrib/python/traitlets/py3/traitlets/config/sphinxdoc.py
index 635b6bdfa3..e4708a2270 100644
--- a/contrib/python/traitlets/py3/traitlets/config/sphinxdoc.py
+++ b/contrib/python/traitlets/py3/traitlets/config/sphinxdoc.py
@@ -50,8 +50,7 @@ def setup(app: t.Any) -> dict[str, t.Any]:
module instead.
"""
app.add_object_type("configtrait", "configtrait", objname="Config option")
- metadata = {"parallel_read_safe": True, "parallel_write_safe": True}
- return metadata
+ return {"parallel_read_safe": True, "parallel_write_safe": True}
def interesting_default_value(dv: t.Any) -> bool:
diff --git a/contrib/python/traitlets/py3/traitlets/log.py b/contrib/python/traitlets/py3/traitlets/log.py
index d90a9c5284..112b200442 100644
--- a/contrib/python/traitlets/py3/traitlets/log.py
+++ b/contrib/python/traitlets/py3/traitlets/log.py
@@ -16,7 +16,7 @@ def get_logger() -> logging.Logger | logging.LoggerAdapter[Any]:
If a global Application is instantiated, grab its logger.
Otherwise, grab the root logger.
"""
- global _logger
+ global _logger # noqa: PLW0603
if _logger is None:
from .config import Application
diff --git a/contrib/python/traitlets/py3/traitlets/tests/utils.py b/contrib/python/traitlets/py3/traitlets/tests/utils.py
index 9552a5c786..254d46a758 100644
--- a/contrib/python/traitlets/py3/traitlets/tests/utils.py
+++ b/contrib/python/traitlets/py3/traitlets/tests/utils.py
@@ -10,7 +10,7 @@ def get_output_error_code(cmd: str | Sequence[str]) -> tuple[str, str, Any]:
import os
env = os.environ.copy()
env["Y_PYTHON_ENTRY_POINT"] = ":main"
- p = Popen(cmd, stdout=PIPE, stderr=PIPE, env=env) # noqa
+ p = Popen(cmd, stdout=PIPE, stderr=PIPE, env=env) # noqa: S603
out, err = p.communicate()
out_str = out.decode("utf8", "replace")
err_str = err.decode("utf8", "replace")
diff --git a/contrib/python/traitlets/py3/traitlets/traitlets.py b/contrib/python/traitlets/py3/traitlets/traitlets.py
index b3657ab950..1d1675ab0c 100644
--- a/contrib/python/traitlets/py3/traitlets/traitlets.py
+++ b/contrib/python/traitlets/py3/traitlets/traitlets.py
@@ -476,7 +476,6 @@ class BaseDescriptor:
:meth:`BaseDescriptor.instance_init` method of descriptors holding
other descriptors.
"""
- pass
G = TypeVar("G")
@@ -714,8 +713,7 @@ class TraitType(BaseDescriptor, t.Generic[G, S]):
"""
if self.read_only:
raise TraitError('The "%s" trait is read-only.' % self.name)
- else:
- self.set(obj, value)
+ self.set(obj, value)
def _validate(self, obj: t.Any, value: t.Any) -> G | None:
if value is None and self.allow_none:
@@ -810,27 +808,27 @@ class TraitType(BaseDescriptor, t.Generic[G, S]):
),
)
raise error
+
+ # this trait caused an error
+ if self.name is None:
+ # this is not the root trait
+ raise TraitError(value, info or self.info(), self)
+
+ # this is the root trait
+ if obj is not None:
+ e = "The '{}' trait of {} instance expected {}, not {}.".format(
+ self.name,
+ class_of(obj),
+ info or self.info(),
+ describe("the", value),
+ )
else:
- # this trait caused an error
- if self.name is None:
- # this is not the root trait
- raise TraitError(value, info or self.info(), self)
- else:
- # this is the root trait
- if obj is not None:
- e = "The '{}' trait of {} instance expected {}, not {}.".format(
- self.name,
- class_of(obj),
- info or self.info(),
- describe("the", value),
- )
- else:
- e = "The '{}' trait expected {}, not {}.".format(
- self.name,
- info or self.info(),
- describe("the", value),
- )
- raise TraitError(e)
+ e = "The '{}' trait expected {}, not {}.".format(
+ self.name,
+ info or self.info(),
+ describe("the", value),
+ )
+ raise TraitError(e)
def get_metadata(self, key: str, default: t.Any = None) -> t.Any:
"""DEPRECATED: Get a metadata value.
@@ -905,7 +903,7 @@ class _CallbackWrapper:
if self.nargs > 4:
raise TraitError("a trait changed callback must have 0-4 arguments.")
- def __eq__(self, other: t.Any) -> bool:
+ def __eq__(self, other: object) -> bool:
# The wrapper is equal to the wrapped element
if isinstance(other, _CallbackWrapper):
return bool(self.cb == other.cb)
@@ -941,7 +939,7 @@ class MetaHasDescriptors(type):
"""
def __new__(
- mcls: type[MetaHasDescriptors], # noqa: N804
+ mcls: type[MetaHasDescriptors],
name: str,
bases: tuple[type, ...],
classdict: dict[str, t.Any],
@@ -993,7 +991,7 @@ class MetaHasDescriptors(type):
class MetaHasTraits(MetaHasDescriptors):
"""A metaclass for HasTraits."""
- def setup_class(cls: MetaHasTraits, classdict: dict[str, t.Any]) -> None: # noqa
+ def setup_class(cls: MetaHasTraits, classdict: dict[str, t.Any]) -> None:
# for only the current class
cls._trait_default_generators: dict[str, t.Any] = {}
# also looking at base classes
@@ -1490,7 +1488,7 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
self.set_trait(name, value)
except TraitError as e:
# Roll back in case of TraitError during final cross validation.
- self.notify_change = lambda x: None # type:ignore[method-assign, assignment]
+ self.notify_change = lambda x: None # type:ignore[method-assign, assignment] # noqa: ARG005
for name, changes in cache.items():
for change in changes[::-1]:
# TODO: Separate in a rollback function per notification type.
@@ -1763,8 +1761,7 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
cls = self.__class__
if not self.has_trait(name):
raise TraitError(f"Class {cls.__name__} does not have a trait named {name}")
- else:
- getattr(cls, name).set(self, value)
+ getattr(cls, name).set(self, value)
@classmethod
def class_trait_names(cls: type[HasTraits], **metadata: t.Any) -> list[str]:
@@ -2363,16 +2360,12 @@ class ForwardDeclaredType(ForwardDeclaredMixin, Type[G, S]):
Forward-declared version of Type.
"""
- pass
-
class ForwardDeclaredInstance(ForwardDeclaredMixin, Instance[T]):
"""
Forward-declared version of Instance.
"""
- pass
-
class This(ClassBasedTraitType[t.Optional[T], t.Optional[T]]):
"""A trait for instances of the class containing this trait.
@@ -4010,8 +4003,7 @@ class Dict(Instance["dict[K, V]"]):
value = super().validate(obj, value)
if value is None:
return value
- value_dict = self.validate_elements(obj, value)
- return value_dict
+ return self.validate_elements(obj, value)
def validate_elements(self, obj: t.Any, value: dict[t.Any, t.Any]) -> dict[K, V] | None:
per_key_override = self._per_key_traits or {}
diff --git a/contrib/python/traitlets/py3/traitlets/utils/decorators.py b/contrib/python/traitlets/py3/traitlets/utils/decorators.py
index 8090636bc8..5b77d701de 100644
--- a/contrib/python/traitlets/py3/traitlets/utils/decorators.py
+++ b/contrib/python/traitlets/py3/traitlets/utils/decorators.py
@@ -1,4 +1,5 @@
"""Useful decorators for Traitlets users."""
+from __future__ import annotations
import copy
from inspect import Parameter, Signature, signature
diff --git a/contrib/python/traitlets/py3/traitlets/utils/descriptions.py b/contrib/python/traitlets/py3/traitlets/utils/descriptions.py
index 785ec58116..703037163a 100644
--- a/contrib/python/traitlets/py3/traitlets/utils/descriptions.py
+++ b/contrib/python/traitlets/py3/traitlets/utils/descriptions.py
@@ -179,5 +179,4 @@ def repr_type(obj: Any) -> str:
error messages.
"""
the_type = type(obj)
- msg = f"{obj!r} {the_type!r}"
- return msg
+ return f"{obj!r} {the_type!r}"
diff --git a/contrib/python/traitlets/py3/traitlets/utils/getargspec.py b/contrib/python/traitlets/py3/traitlets/utils/getargspec.py
index 7cbc82659c..72c9120cb9 100644
--- a/contrib/python/traitlets/py3/traitlets/utils/getargspec.py
+++ b/contrib/python/traitlets/py3/traitlets/utils/getargspec.py
@@ -7,6 +7,8 @@
:copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
+from __future__ import annotations
+
import inspect
from functools import partial
from typing import Any
diff --git a/contrib/python/traitlets/py3/traitlets/utils/importstring.py b/contrib/python/traitlets/py3/traitlets/utils/importstring.py
index 413c2033c1..203f79f054 100644
--- a/contrib/python/traitlets/py3/traitlets/utils/importstring.py
+++ b/contrib/python/traitlets/py3/traitlets/utils/importstring.py
@@ -3,6 +3,8 @@ A simple utility to import something by its string name.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
+from __future__ import annotations
+
from typing import Any
diff --git a/contrib/python/traitlets/py3/traitlets/utils/nested_update.py b/contrib/python/traitlets/py3/traitlets/utils/nested_update.py
index 37e2d27cd2..33a5ab8a77 100644
--- a/contrib/python/traitlets/py3/traitlets/utils/nested_update.py
+++ b/contrib/python/traitlets/py3/traitlets/utils/nested_update.py
@@ -1,5 +1,7 @@
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
+from __future__ import annotations
+
from typing import Any, Dict
diff --git a/contrib/python/traitlets/py3/traitlets/utils/text.py b/contrib/python/traitlets/py3/traitlets/utils/text.py
index 72ad98fc2a..1c1ac20815 100644
--- a/contrib/python/traitlets/py3/traitlets/utils/text.py
+++ b/contrib/python/traitlets/py3/traitlets/utils/text.py
@@ -1,6 +1,7 @@
"""
Utilities imported from ipython_genutils
"""
+from __future__ import annotations
import re
import textwrap
@@ -10,8 +11,7 @@ from typing import List
def indent(val: str) -> str:
- res = _indent(val, " ")
- return res
+ return _indent(val, " ")
def wrap_paragraphs(text: str, ncols: int = 80) -> List[str]:
diff --git a/contrib/python/traitlets/py3/ya.make b/contrib/python/traitlets/py3/ya.make
index 2384990112..fffcd05afd 100644
--- a/contrib/python/traitlets/py3/ya.make
+++ b/contrib/python/traitlets/py3/ya.make
@@ -4,7 +4,7 @@ PY3_LIBRARY()
PROVIDES(python_traitlets)
-VERSION(5.14.0)
+VERSION(5.14.1)
LICENSE(BSD-3-Clause)