@@ -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