Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#852)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Steven Silvester <steven.silvester@ieee.org>
  • Loading branch information
pre-commit-ci[bot] and blink1073 committed Aug 1, 2023
1 parent c2d04ba commit 05d6ecb
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 18 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.23.2
rev: 0.23.3
hooks:
- id: check-github-workflows

Expand All @@ -29,12 +29,12 @@ repos:
- id: mdformat

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.276
rev: v0.0.281
hooks:
- id: ruff
args: ["--fix"]
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencies = ["mypy>=0.990"]
test = "mypy --install-types --non-interactive {args:.}"

[tool.hatch.envs.lint]
dependencies = ["black==23.3.0", "mdformat>0.7", "ruff==0.0.276"]
dependencies = ["black==23.3.0", "mdformat>0.7", "ruff==0.0.281"]
detached = true
[tool.hatch.envs.lint.scripts]
style = [
Expand Down
4 changes: 1 addition & 3 deletions traitlets/config/configurable.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,7 @@ def warn(msg):
return warnings.warn(msg, UserWarning, stacklevel=9)

matches = get_close_matches(name, traits)
msg = "Config option `{option}` not recognized by `{klass}`.".format(
option=name, klass=self.__class__.__name__
)
msg = f"Config option `{name}` not recognized by `{self.__class__.__name__}`."

if len(matches) == 1:
msg += f" Did you mean `{matches[0]}`?"
Expand Down
4 changes: 2 additions & 2 deletions traitlets/config/sphinxdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ def reverse_aliases(app):
# Treat flags which set one trait to True as aliases.
for flag, (cfg, _) in app.flags.items():
if len(cfg) == 1:
classname = list(cfg)[0]
classname = next(iter(cfg))
cls_cfg = cfg[classname]
if len(cls_cfg) == 1:
traitname = list(cls_cfg)[0]
traitname = next(iter(cls_cfg))
if cls_cfg[traitname] is True:
res[classname + "." + traitname].append(flag)

Expand Down
10 changes: 4 additions & 6 deletions traitlets/traitlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2903,7 +2903,8 @@ def from_string_list(self, s_list):
item_from_string = self.item_from_string
else:
# backward-compat: allow item_from_string to ignore index arg
item_from_string = lambda s, index=None: self.item_from_string(s) # noqa[E371]
def item_from_string(s, index=None):
return self.item_from_string(s) # noqa[E371]

return self.klass(
[item_from_string(s, index=idx) for idx, s in enumerate(s_list)]
Expand Down Expand Up @@ -3426,10 +3427,7 @@ def item_from_string(self, s):

if "=" not in s:
raise TraitError(
"'{}' options must have the form 'key=value', got {}".format(
self.__class__.__name__,
repr(s),
)
f"'{self.__class__.__name__}' options must have the form 'key=value', got {s!r}"
)
key, value = s.split("=", 1)

Expand Down Expand Up @@ -3521,7 +3519,7 @@ def __init__(self, enum_class, default_value=None, **kwargs):
assert issubclass(enum_class, enum.Enum), "REQUIRE: enum.Enum, but was: %r" % enum_class
allow_none = kwargs.get("allow_none", False)
if default_value is None and not allow_none:
default_value = list(enum_class.__members__.values())[0]
default_value = next(iter(enum_class.__members__.values()))
super().__init__(default_value=default_value, **kwargs)
self.enum_class = enum_class
self.name_prefix = enum_class.__name__ + "."
Expand Down
4 changes: 1 addition & 3 deletions traitlets/utils/warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ def deprecated_method(method, cls, method_name, msg):
Uses warn_explicit to bind warning to method definition instead of triggering code,
which isn't relevant.
"""
warn_msg = "{classname}.{method_name} is deprecated in traitlets 4.1: {msg}".format(
classname=cls.__name__, method_name=method_name, msg=msg
)
warn_msg = f"{cls.__name__}.{method_name} is deprecated in traitlets 4.1: {msg}"

for parent in inspect.getmro(cls):
if method_name in parent.__dict__:
Expand Down

0 comments on commit 05d6ecb

Please sign in to comment.