Skip to content

Commit a5f0718

Browse files
[pre-commit.ci] pre-commit autoupdate (#857)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 05d6ecb commit a5f0718

File tree

5 files changed

+25
-41
lines changed

5 files changed

+25
-41
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ repos:
1919
- id: trailing-whitespace
2020

2121
- repo: https://github.com/python-jsonschema/check-jsonschema
22-
rev: 0.23.3
22+
rev: 0.26.3
2323
hooks:
2424
- id: check-github-workflows
2525

2626
- repo: https://github.com/executablebooks/mdformat
27-
rev: 0.7.16
27+
rev: 0.7.17
2828
hooks:
2929
- id: mdformat
3030

@@ -34,7 +34,7 @@ repos:
3434
- id: black
3535

3636
- repo: https://github.com/astral-sh/ruff-pre-commit
37-
rev: v0.0.281
37+
rev: v0.0.287
3838
hooks:
3939
- id: ruff
4040
args: ["--fix"]

traitlets/config/application.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,7 @@ def start_show_config(self):
503503

504504
for traitname in sorted(class_config):
505505
value = class_config[traitname]
506-
print(
507-
" .{} = {}".format(
508-
traitname,
509-
pprint.pformat(value, **pformat_kwargs),
510-
)
511-
)
506+
print(f" .{traitname} = {pprint.pformat(value, **pformat_kwargs)}")
512507

513508
def print_alias_help(self):
514509
"""Print the alias parts of the help."""

traitlets/config/configurable.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,8 @@ def instance(cls, *args, **kwargs):
560560
return cls._instance
561561
else:
562562
raise MultipleInstanceError(
563-
"An incompatible sibling of '{}' is already instantiated"
564-
" as singleton: {}".format(cls.__name__, type(cls._instance).__name__)
563+
f"An incompatible sibling of '{cls.__name__}' is already instantiated"
564+
f" as singleton: {type(cls._instance).__name__}"
565565
)
566566

567567
@classmethod

traitlets/config/loader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def __setitem__(self, key, value):
348348
if not isinstance(value, Config):
349349
raise ValueError(
350350
"values whose keys begin with an uppercase "
351-
"char must be Config instances: {!r}, {!r}".format(key, value)
351+
f"char must be Config instances: {key!r}, {value!r}"
352352
)
353353
dict.__setitem__(self, key, value)
354354

@@ -1036,8 +1036,8 @@ def _add_arguments(self, aliases, flags, classes):
10361036
# flag sets 'action', so can't have flag & alias with custom action
10371037
# on the same name
10381038
raise ArgumentError(
1039-
"The alias `{}` for the 'append' sequence "
1040-
"config-trait `{}` cannot be also a flag!'".format(key, traitname)
1039+
f"The alias `{key}` for the 'append' sequence "
1040+
f"config-trait `{traitname}` cannot be also a flag!'"
10411041
)
10421042
# For argcomplete, check if any either an argcompleter metadata tag or method
10431043
# is available. If so, it should be a callable which takes the command-line key

traitlets/traitlets.py

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,7 @@ def _update_target(self, change):
322322
setattr(self.target[0], self.target[1], self._transform(change.new))
323323
if getattr(self.source[0], self.source[1]) != change.new:
324324
raise TraitError(
325-
"Broken link {}: the source value changed while updating "
326-
"the target.".format(self)
325+
f"Broken link {self}: the source value changed while updating " "the target."
327326
)
328327

329328
def _update_source(self, change):
@@ -333,8 +332,7 @@ def _update_source(self, change):
333332
setattr(self.source[0], self.source[1], self._transform_inv(change.new))
334333
if getattr(self.target[0], self.target[1]) != change.new:
335334
raise TraitError(
336-
"Broken link {}: the target value changed while updating "
337-
"the source.".format(self)
335+
f"Broken link {self}: the target value changed while updating " "the source."
338336
)
339337

340338
def unlink(self):
@@ -532,9 +530,9 @@ def __init__(
532530
key = ("metadata-tag", pkg, *sorted(kwargs))
533531
if should_warn(key):
534532
warn(
535-
"metadata {} was set from the constructor. "
533+
f"metadata {kwargs} was set from the constructor. "
536534
"With traitlets 4.1, metadata should be set using the .tag() method, "
537-
"e.g., Int().tag(key1='value1', key2='value2')".format(kwargs),
535+
"e.g., Int().tag(key1='value1', key2='value2')",
538536
DeprecationWarning,
539537
stacklevel=stacklevel,
540538
)
@@ -2006,8 +2004,8 @@ def validate(self, obj, value):
20062004
value = self._resolve_string(value)
20072005
except ImportError as e:
20082006
raise TraitError(
2009-
"The '{}' trait of {} instance must be a type, but "
2010-
"{!r} could not be imported".format(self.name, obj, value)
2007+
f"The '{self.name}' trait of {obj} instance must be a type, but "
2008+
f"{value!r} could not be imported"
20112009
) from e
20122010
try:
20132011
if issubclass(value, self.klass): # type:ignore[arg-type]
@@ -2308,19 +2306,15 @@ def _validate_bounds(trait, obj, value):
23082306
"""
23092307
if trait.min is not None and value < trait.min:
23102308
raise TraitError(
2311-
"The value of the '{name}' trait of {klass} instance should "
2312-
"not be less than {min_bound}, but a value of {value} was "
2313-
"specified".format(
2314-
name=trait.name, klass=class_of(obj), value=value, min_bound=trait.min
2315-
)
2309+
f"The value of the '{trait.name}' trait of {class_of(obj)} instance should "
2310+
f"not be less than {trait.min}, but a value of {value} was "
2311+
"specified"
23162312
)
23172313
if trait.max is not None and value > trait.max:
23182314
raise TraitError(
2319-
"The value of the '{name}' trait of {klass} instance should "
2320-
"not be greater than {max_bound}, but a value of {value} was "
2321-
"specified".format(
2322-
name=trait.name, klass=class_of(obj), value=value, max_bound=trait.max
2323-
)
2315+
f"The value of the '{trait.name}' trait of {class_of(obj)} instance should "
2316+
f"not be greater than {trait.max}, but a value of {value} was "
2317+
"specified"
23242318
)
23252319
return value
23262320

@@ -2460,7 +2454,7 @@ def from_string(self, s):
24602454
s = s[2:-1]
24612455
warn(
24622456
"Supporting extra quotes around Bytes is deprecated in traitlets 5.0. "
2463-
"Use {!r} instead of {!r}.".format(s, old_s),
2457+
f"Use {s!r} instead of {old_s!r}.",
24642458
DeprecationWarning,
24652459
stacklevel=2,
24662460
)
@@ -2510,9 +2504,7 @@ def from_string(self, s):
25102504
s = s[1:-1]
25112505
warn(
25122506
"Supporting extra quotes around strings is deprecated in traitlets 5.0. "
2513-
"You can use {!r} instead of {!r} if you require traitlets >=5.".format(
2514-
s, old_s
2515-
),
2507+
f"You can use {s!r} instead of {old_s!r} if you require traitlets >=5.",
25162508
DeprecationWarning,
25172509
stacklevel=2,
25182510
)
@@ -3398,11 +3390,8 @@ def from_string_list(self, s_list):
33983390
return None
33993391
if len(s_list) == 1 and s_list[0].startswith("{") and s_list[0].endswith("}"):
34003392
warn(
3401-
"--{0}={1} for dict-traits is deprecated in traitlets 5.0. "
3402-
"You can pass --{0} <key=value> ... multiple times to add items to a dict.".format(
3403-
self.name,
3404-
s_list[0],
3405-
),
3393+
f"--{self.name}={s_list[0]} for dict-traits is deprecated in traitlets 5.0. "
3394+
f"You can pass --{self.name} <key=value> ... multiple times to add items to a dict.",
34063395
DeprecationWarning,
34073396
stacklevel=2,
34083397
)

0 commit comments

Comments
 (0)