@@ -113,8 +113,8 @@ def only_deprecated(self):
113
113
114
114
def diff (self , other ):
115
115
if not isinstance (other , ClassItem ):
116
- raise TypeError ("Expect a {} instance as argument. "
117
- "Got a {} instance instead" . format ( ClassItem . __name__ , type (other ).__name__ ) )
116
+ raise TypeError (f "Expect a { ClassItem . __name__ } instance as argument. "
117
+ f "Got a { type (other ).__name__ } instance instead" )
118
118
diff_item = ClassItem (self .class_ )
119
119
diff_item .attrs = {k : v for k , v in self .attrs .items () if k not in other .attrs }
120
120
diff_item .methods = {k : v for k , v in self .methods .items () if k not in other .methods }
@@ -128,15 +128,15 @@ def write(self, ofile):
128
128
_write_header (ofile , self .name , '=' , indent = indent )
129
129
if self .attrs :
130
130
_write_header (ofile , 'Attributes' , indent = indent )
131
- ofile .writelines (indent + ' * {}\n '. format ( attr ) for attr in self .attrs .keys ())
131
+ ofile .writelines (f' { indent } * { attr } \n ' for attr in self .attrs .keys ())
132
132
ofile .write ('\n ' )
133
133
if self .methods :
134
134
_write_header (ofile , 'Methods' , indent = indent )
135
- ofile .writelines (indent + ' * {}\n '. format ( method ) for method in self .methods .keys ())
135
+ ofile .writelines (f' { indent } * { method } \n ' for method in self .methods .keys ())
136
136
ofile .write ('\n ' )
137
137
if self .deprecated_methods :
138
138
_write_header (ofile , 'Deprecated Methods' , indent = indent )
139
- ofile .writelines (indent + ' * {}\n '. format ( method ) for method in self .deprecated_methods .keys ())
139
+ ofile .writelines (f' { indent } * { method } \n ' for method in self .deprecated_methods .keys ())
140
140
ofile .write ('\n ' )
141
141
ofile .write ('\n ' )
142
142
@@ -182,6 +182,7 @@ def insert_element(self, name, obj):
182
182
self .funcs [name ] = obj
183
183
elif inspect .isclass (obj ):
184
184
if name in self .classes :
185
+ # FIXME: missing format or fstring
185
186
warnings .warn ("Class '{}' was already present in '{}' module item and will be replaced" )
186
187
class_ = getattr (self .module , name )
187
188
class_item = ClassItem (class_ )
@@ -210,8 +211,8 @@ def only_deprecated(self):
210
211
211
212
def diff (self , other ):
212
213
if not isinstance (other , ModuleItem ):
213
- raise TypeError ("Expect a {} instance as argument. "
214
- "Got a {} instance instead" . format ( ModuleItem . __name__ , type (other ).__name__ ) )
214
+ raise TypeError (f "Expect a { ModuleItem . __name__ } instance as argument. "
215
+ f "Got a { type (other ).__name__ } instance instead" )
215
216
diff_item = ModuleItem (self .module )
216
217
diff_item .others = {k : v for k , v in self .others .items () if k not in other .others }
217
218
diff_item .funcs = {k : v for k , v in self .funcs .items () if k not in other .funcs }
@@ -227,15 +228,15 @@ def write(self, ofile):
227
228
ofile .write ('\n ' )
228
229
if self .others :
229
230
_write_header (ofile , 'Miscellaneous' , '=' )
230
- ofile .writelines (' * {}\n ' . format ( other ) for other in self .others .keys ())
231
+ ofile .writelines (f ' * { other } \n ' for other in self .others .keys ())
231
232
ofile .write ('\n ' )
232
233
if self .funcs :
233
234
_write_header (ofile , 'Functions' , '=' )
234
- ofile .writelines (' * {}\n ' . format ( func ) for func in self .funcs .keys ())
235
+ ofile .writelines (f ' * { func } \n ' for func in self .funcs .keys ())
235
236
ofile .write ('\n ' )
236
237
if self .deprecated_items :
237
238
_write_header (ofile , 'Deprecated Functions or Classes' , '=' )
238
- ofile .writelines (' * {}\n ' . format ( func ) for func in self .deprecated_items .keys ())
239
+ ofile .writelines (f ' * { func } \n ' for func in self .deprecated_items .keys ())
239
240
ofile .write ('\n ' )
240
241
if self .classes :
241
242
_write_header (ofile , 'Classes' , '=' )
@@ -270,7 +271,7 @@ def get_public_api():
270
271
module_item .auto_discovery ()
271
272
public_api [module_name ] = module_item
272
273
except ImportError as err :
273
- print ('module {} could not be imported: {}' . format ( module_name , err ) )
274
+ print (f 'module { module_name } could not be imported: { err } ' )
274
275
public_api [module_name ] = err
275
276
return public_api
276
277
@@ -294,7 +295,7 @@ def get_autosummary_api():
294
295
module_item = ModuleItem (module )
295
296
autosummary_api [module_name ] = module_item
296
297
except ImportError as err :
297
- print ('module {} could not be imported: {}' . format ( module_name , err ) )
298
+ print (f 'module { module_name } could not be imported: { err } ' )
298
299
autosummary_api [module_name ] = err
299
300
300
301
for generated_rst_file in os .listdir (output_dir ):
@@ -327,7 +328,7 @@ def write_api(filepath, api, header='API', version=True):
327
328
failed = []
328
329
with open (output_file , 'w' ) as ofile :
329
330
if version :
330
- header = '{ } [{}]'. format ( header , __version__ )
331
+ header = f' { header } [{ __version__ } ]'
331
332
_write_header (ofile , header , '~' )
332
333
ofile .write ('\n ' )
333
334
keys = sorted (api .keys ())
@@ -341,7 +342,7 @@ def write_api(filepath, api, header='API', version=True):
341
342
342
343
if failed :
343
344
_write_header (ofile , 'Modules that failed to import' )
344
- ofile .writelines (' * {} -- {}\n ' . format ( module_name , error ) for module_name , error in failed )
345
+ ofile .writelines (f ' * { module_name } -- { error } \n ' for module_name , error in failed )
345
346
346
347
347
348
def get_items_from_api_doc ():
0 commit comments