@@ -2903,7 +2903,8 @@ def from_string_list(self, s_list):
29032903 item_from_string = self .item_from_string
29042904 else :
29052905 # backward-compat: allow item_from_string to ignore index arg
2906- item_from_string = lambda s , index = None : self .item_from_string (s ) # noqa[E371]
2906+ def item_from_string (s , index = None ):
2907+ return self .item_from_string (s ) # noqa[E371]
29072908
29082909 return self .klass (
29092910 [item_from_string (s , index = idx ) for idx , s in enumerate (s_list )]
@@ -3426,10 +3427,7 @@ def item_from_string(self, s):
34263427
34273428 if "=" not in s :
34283429 raise TraitError (
3429- "'{}' options must have the form 'key=value', got {}" .format (
3430- self .__class__ .__name__ ,
3431- repr (s ),
3432- )
3430+ f"'{ self .__class__ .__name__ } ' options must have the form 'key=value', got { s !r} "
34333431 )
34343432 key , value = s .split ("=" , 1 )
34353433
@@ -3521,7 +3519,7 @@ def __init__(self, enum_class, default_value=None, **kwargs):
35213519 assert issubclass (enum_class , enum .Enum ), "REQUIRE: enum.Enum, but was: %r" % enum_class
35223520 allow_none = kwargs .get ("allow_none" , False )
35233521 if default_value is None and not allow_none :
3524- default_value = list ( enum_class .__members__ .values ())[ 0 ]
3522+ default_value = next ( iter ( enum_class .__members__ .values ()))
35253523 super ().__init__ (default_value = default_value , ** kwargs )
35263524 self .enum_class = enum_class
35273525 self .name_prefix = enum_class .__name__ + "."
0 commit comments