Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#857)
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>
  • Loading branch information
pre-commit-ci[bot] committed Sep 5, 2023
1 parent 05d6ecb commit a5f0718
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 41 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ repos:
- id: trailing-whitespace

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

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
rev: 0.7.17
hooks:
- id: mdformat

Expand All @@ -34,7 +34,7 @@ repos:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.281
rev: v0.0.287
hooks:
- id: ruff
args: ["--fix"]
7 changes: 1 addition & 6 deletions traitlets/config/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,12 +503,7 @@ def start_show_config(self):

for traitname in sorted(class_config):
value = class_config[traitname]
print(
" .{} = {}".format(
traitname,
pprint.pformat(value, **pformat_kwargs),
)
)
print(f" .{traitname} = {pprint.pformat(value, **pformat_kwargs)}")

def print_alias_help(self):
"""Print the alias parts of the help."""
Expand Down
4 changes: 2 additions & 2 deletions traitlets/config/configurable.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,8 @@ def instance(cls, *args, **kwargs):
return cls._instance
else:
raise MultipleInstanceError(
"An incompatible sibling of '{}' is already instantiated"
" as singleton: {}".format(cls.__name__, type(cls._instance).__name__)
f"An incompatible sibling of '{cls.__name__}' is already instantiated"
f" as singleton: {type(cls._instance).__name__}"
)

@classmethod
Expand Down
6 changes: 3 additions & 3 deletions traitlets/config/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def __setitem__(self, key, value):
if not isinstance(value, Config):
raise ValueError(
"values whose keys begin with an uppercase "
"char must be Config instances: {!r}, {!r}".format(key, value)
f"char must be Config instances: {key!r}, {value!r}"
)
dict.__setitem__(self, key, value)

Expand Down Expand Up @@ -1036,8 +1036,8 @@ def _add_arguments(self, aliases, flags, classes):
# flag sets 'action', so can't have flag & alias with custom action
# on the same name
raise ArgumentError(
"The alias `{}` for the 'append' sequence "
"config-trait `{}` cannot be also a flag!'".format(key, traitname)
f"The alias `{key}` for the 'append' sequence "
f"config-trait `{traitname}` cannot be also a flag!'"
)
# For argcomplete, check if any either an argcompleter metadata tag or method
# is available. If so, it should be a callable which takes the command-line key
Expand Down
43 changes: 16 additions & 27 deletions traitlets/traitlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,7 @@ def _update_target(self, change):
setattr(self.target[0], self.target[1], self._transform(change.new))
if getattr(self.source[0], self.source[1]) != change.new:
raise TraitError(
"Broken link {}: the source value changed while updating "
"the target.".format(self)
f"Broken link {self}: the source value changed while updating " "the target."
)

def _update_source(self, change):
Expand All @@ -333,8 +332,7 @@ def _update_source(self, change):
setattr(self.source[0], self.source[1], self._transform_inv(change.new))
if getattr(self.target[0], self.target[1]) != change.new:
raise TraitError(
"Broken link {}: the target value changed while updating "
"the source.".format(self)
f"Broken link {self}: the target value changed while updating " "the source."
)

def unlink(self):
Expand Down Expand Up @@ -532,9 +530,9 @@ def __init__(
key = ("metadata-tag", pkg, *sorted(kwargs))
if should_warn(key):
warn(
"metadata {} was set from the constructor. "
f"metadata {kwargs} was set from the constructor. "
"With traitlets 4.1, metadata should be set using the .tag() method, "
"e.g., Int().tag(key1='value1', key2='value2')".format(kwargs),
"e.g., Int().tag(key1='value1', key2='value2')",
DeprecationWarning,
stacklevel=stacklevel,
)
Expand Down Expand Up @@ -2006,8 +2004,8 @@ def validate(self, obj, value):
value = self._resolve_string(value)
except ImportError as e:
raise TraitError(
"The '{}' trait of {} instance must be a type, but "
"{!r} could not be imported".format(self.name, obj, value)
f"The '{self.name}' trait of {obj} instance must be a type, but "
f"{value!r} could not be imported"
) from e
try:
if issubclass(value, self.klass): # type:ignore[arg-type]
Expand Down Expand Up @@ -2308,19 +2306,15 @@ def _validate_bounds(trait, obj, value):
"""
if trait.min is not None and value < trait.min:
raise TraitError(
"The value of the '{name}' trait of {klass} instance should "
"not be less than {min_bound}, but a value of {value} was "
"specified".format(
name=trait.name, klass=class_of(obj), value=value, min_bound=trait.min
)
f"The value of the '{trait.name}' trait of {class_of(obj)} instance should "
f"not be less than {trait.min}, but a value of {value} was "
"specified"
)
if trait.max is not None and value > trait.max:
raise TraitError(
"The value of the '{name}' trait of {klass} instance should "
"not be greater than {max_bound}, but a value of {value} was "
"specified".format(
name=trait.name, klass=class_of(obj), value=value, max_bound=trait.max
)
f"The value of the '{trait.name}' trait of {class_of(obj)} instance should "
f"not be greater than {trait.max}, but a value of {value} was "
"specified"
)
return value

Expand Down Expand Up @@ -2460,7 +2454,7 @@ def from_string(self, s):
s = s[2:-1]
warn(
"Supporting extra quotes around Bytes is deprecated in traitlets 5.0. "
"Use {!r} instead of {!r}.".format(s, old_s),
f"Use {s!r} instead of {old_s!r}.",
DeprecationWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -2510,9 +2504,7 @@ def from_string(self, s):
s = s[1:-1]
warn(
"Supporting extra quotes around strings is deprecated in traitlets 5.0. "
"You can use {!r} instead of {!r} if you require traitlets >=5.".format(
s, old_s
),
f"You can use {s!r} instead of {old_s!r} if you require traitlets >=5.",
DeprecationWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -3398,11 +3390,8 @@ def from_string_list(self, s_list):
return None
if len(s_list) == 1 and s_list[0].startswith("{") and s_list[0].endswith("}"):
warn(
"--{0}={1} for dict-traits is deprecated in traitlets 5.0. "
"You can pass --{0} <key=value> ... multiple times to add items to a dict.".format(
self.name,
s_list[0],
),
f"--{self.name}={s_list[0]} for dict-traits is deprecated in traitlets 5.0. "
f"You can pass --{self.name} <key=value> ... multiple times to add items to a dict.",
DeprecationWarning,
stacklevel=2,
)
Expand Down

0 comments on commit a5f0718

Please sign in to comment.