@@ -217,14 +217,10 @@ def _parse_module_with_import(self, uri):
217217 continue
218218 obj = mod .__dict__ [obj_str ]
219219 # Check if function / class defined in module
220- if not self .other_defines and not getmodule (obj ) = = mod :
220+ if not self .other_defines and getmodule (obj ) ! = mod :
221221 continue
222222 # figure out if obj is a function or class
223- if (
224- hasattr (obj , 'func_name' )
225- or isinstance (obj , BuiltinFunctionType )
226- or isinstance (obj , FunctionType )
227- ):
223+ if hasattr (obj , 'func_name' ) or isinstance (obj , (BuiltinFunctionType , FunctionType )):
228224 functions .append (obj_str )
229225 else :
230226 try :
@@ -278,7 +274,7 @@ def generate_api_doc(self, uri):
278274
279275 # Make a shorter version of the uri that omits the package name for
280276 # titles
281- uri_short = re .sub (r'^%s\.' % self .package_name , '' , uri )
277+ uri_short = re .sub (rf'^ { self .package_name } \.' , '' , uri )
282278
283279 head = '.. AUTO-GENERATED FILE -- DO NOT EDIT!\n \n '
284280 body = ''
@@ -345,7 +341,7 @@ def _survives_exclude(self, matchstr, match_type):
345341 elif match_type == 'package' :
346342 patterns = self .package_skip_patterns
347343 else :
348- raise ValueError ('Cannot interpret match type "%s"' % match_type )
344+ raise ValueError (f 'Cannot interpret match type "{ match_type } "' )
349345 # Match to URI without package name
350346 L = len (self .package_name )
351347 if matchstr [:L ] == self .package_name :
@@ -426,7 +422,7 @@ def write_modules_api(self, modules, outdir):
426422 written_modules = []
427423
428424 for ulm , mods in module_by_ulm .items ():
429- print ('Generating docs for %s:' % ulm )
425+ print (f 'Generating docs for { ulm } :' )
430426 document_head = []
431427 document_body = []
432428
@@ -506,5 +502,5 @@ def write_index(self, outdir, froot='gen', relative_to=None):
506502 w ('=' * len (title ) + '\n \n ' )
507503 w ('.. toctree::\n \n ' )
508504 for f in self .written_modules :
509- w (' %s \n ' % os .path .join (relpath , f ))
505+ w (f ' { os .path .join (relpath , f )} \n ' )
510506 idx .close ()
0 commit comments