@@ -1979,9 +1979,9 @@ def _make_repr(attrs, ns, cls):
1979
1979
"self." + name if i else 'getattr(self, "' + name + '", NOTHING)'
1980
1980
)
1981
1981
fragment = (
1982
- "{ }={{{}!r}}". format ( name , accessor )
1982
+ f" { name } ={{{ accessor } !r}}"
1983
1983
if r == repr
1984
- else "{ }={{{}_repr({})}}". format ( name , name , accessor )
1984
+ else f" { name } ={{{ name } _repr({ accessor } )}}"
1985
1985
)
1986
1986
attribute_fragments .append (fragment )
1987
1987
repr_fragment = ", " .join (attribute_fragments )
@@ -2208,11 +2208,7 @@ def _setattr_with_converter(attr_name, value_var, has_on_setattr):
2208
2208
Use the cached object.setattr to set *attr_name* to *value_var*, but run
2209
2209
its converter first.
2210
2210
"""
2211
- return "_setattr('{}', {}({}))" .format (
2212
- attr_name ,
2213
- _INIT_CONVERTER_PAT % (attr_name ,),
2214
- value_var ,
2215
- )
2211
+ return f"_setattr('{ attr_name } ', { _INIT_CONVERTER_PAT % (attr_name ,)} ({ value_var } ))"
2216
2212
2217
2213
2218
2214
def _assign (attr_name , value , has_on_setattr ):
@@ -2234,11 +2230,7 @@ def _assign_with_converter(attr_name, value_var, has_on_setattr):
2234
2230
if has_on_setattr :
2235
2231
return _setattr_with_converter (attr_name , value_var , True )
2236
2232
2237
- return "self.{} = {}({})" .format (
2238
- attr_name ,
2239
- _INIT_CONVERTER_PAT % (attr_name ,),
2240
- value_var ,
2241
- )
2233
+ return f"self.{ attr_name } = { _INIT_CONVERTER_PAT % (attr_name ,)} ({ value_var } )"
2242
2234
2243
2235
2244
2236
def _determine_setters (frozen , slots , base_attr_map ):
@@ -2267,11 +2259,7 @@ def fmt_setter_with_converter(attr_name, value_var, has_on_setattr):
2267
2259
attr_name , value_var , has_on_setattr
2268
2260
)
2269
2261
2270
- return "_inst_dict['{}'] = {}({})" .format (
2271
- attr_name ,
2272
- _INIT_CONVERTER_PAT % (attr_name ,),
2273
- value_var ,
2274
- )
2262
+ return f"_inst_dict['{ attr_name } '] = { _INIT_CONVERTER_PAT % (attr_name ,)} ({ value_var } )"
2275
2263
2276
2264
return (
2277
2265
("_inst_dict = self.__dict__" ,),
@@ -2519,7 +2507,7 @@ def _attrs_to_init_script(
2519
2507
", " .join (kw_only_args ), # kw_only args
2520
2508
)
2521
2509
pre_init_kw_only_args = ", " .join (
2522
- ["{ }={}" . format ( kw_arg , kw_arg ) for kw_arg in kw_only_args ]
2510
+ [f" { kw_arg } ={ kw_arg } " for kw_arg in kw_only_args ]
2523
2511
)
2524
2512
pre_init_args += (
2525
2513
", " if pre_init_args else ""
0 commit comments