@@ -81,8 +81,11 @@ def classify_class_attrs(cls):
8181 kind = "class method"
8282 elif isinstance (obj , property ):
8383 kind = "property"
84- elif (inspect .ismethod (obj_via_getattr ) or # noqa: W504
85- inspect .ismethoddescriptor (obj_via_getattr )):
84+ elif inspect .ismethod (
85+ obj_via_getattr
86+ ) or inspect .ismethoddescriptor (
87+ obj_via_getattr
88+ ):
8689 kind = "method"
8790 else :
8891 kind = "data"
@@ -98,24 +101,28 @@ def classify_class_attrs(cls):
98101class DefaultFormatter (pydoc .HTMLDoc ):
99102 """Default formatter."""
100103
101- def docmodule (self , object , name = None , mod = None , packageContext = None , * ignored ): # noqa: C901
104+ def docmodule ( # NOSONAR # noqa: C901
105+ self , object , name = None , mod = None , packageContext = None , * ignored # NOSONAR
106+ ): # noqa: C901
102107 """Produce HTML documentation for a module object."""
103108 my_name = object .__name__ # ignore the passed-in name
104109 parts = split (my_name , "." )
105110 links = []
106111 for i in range (len (parts ) - 1 ):
107112 links .append (
108- "<a href=\" %s.html\" ><font color=\" #ffffff\" >%s</font></a>" %
109- (join (parts [:i + 1 ], "." ), parts [i ]))
113+ '<a href="%s.html"><font color="#ffffff">%s</font></a>'
114+ % (join (parts [: i + 1 ], "." ), parts [i ])
115+ )
110116 linkedname = join (links + parts [- 1 :], "." )
111117 head = "<big><big><strong>%s</strong></big></big>" % linkedname
112118 try :
113119 path = inspect .getabsfile (object )
114120 url = path
115121 if sys .platform == "win32" :
116122 import nturl2path
123+
117124 url = nturl2path .pathname2url (path )
118- filelink = " <a href=\ " file:%s\ " >%s</a>" % (url , path )
125+ filelink = ' <a href="file:%s">%s</a>' % (url , path )
119126 except TypeError :
120127 filelink = "(built-in)"
121128 info = []
@@ -129,7 +136,8 @@ def docmodule(self, object, name=None, mod=None, packageContext=None, *ignored):
129136 if info :
130137 head = head + " (%s)" % join (info , ", " )
131138 result = self .heading (
132- head , "#ffffff" , "#7799ee" , "<a href=\" .\" >index</a><br>" + filelink )
139+ head , "#ffffff" , "#7799ee" , '<a href=".">index</a><br>' + filelink
140+ )
133141
134142 modules = inspect .getmembers (object , inspect .ismodule )
135143
@@ -185,23 +193,25 @@ def docmodule(self, object, name=None, mod=None, packageContext=None, *ignored):
185193 elif modules :
186194 # FIX contents = self.multicolumn(
187195 # FIX modules, lambda (key, value), s=self: s.modulelink(value))
188- result = result + self .bigsection (
189- "Modules" , "#fffff" , "#aa55cc" , contents )
196+ result = result + self .bigsection ("Modules" , "#fffff" , "#aa55cc" , contents )
190197
191198 if classes :
192199 # FIX classlist = map(lambda (key, value): value, classes)
193200 contents = [
194- self .formattree (inspect .getclasstree (classlist , 1 ), my_name )] # noqa: F821
201+ self .formattree (inspect .getclasstree (classlist , 1 ), my_name ) # noqa: F821
202+ ]
195203 for key , value in classes :
196204 contents .append (self .document (value , key , my_name , fdict , cdict ))
197205 result = result + self .bigsection (
198- "Classes" , "#ffffff" , "#ee77aa" , join (contents ))
206+ "Classes" , "#ffffff" , "#ee77aa" , join (contents )
207+ )
199208 if funcs :
200209 contents = []
201210 for key , value in funcs :
202211 contents .append (self .document (value , key , my_name , fdict , cdict ))
203212 result = result + self .bigsection (
204- "Functions" , "#ffffff" , "#eeaa77" , join (contents ))
213+ "Functions" , "#ffffff" , "#eeaa77" , join (contents )
214+ )
205215 if data :
206216 contents = []
207217 for key , value in data :
@@ -210,25 +220,22 @@ def docmodule(self, object, name=None, mod=None, packageContext=None, *ignored):
210220 except Exception : # nosec
211221 pass
212222 result = result + self .bigsection (
213- "Data" , "#ffffff" , "#55aa55" , join (contents , "<br>\n " ))
223+ "Data" , "#ffffff" , "#55aa55" , join (contents , "<br>\n " )
224+ )
214225 if hasattr (object , "__author__" ):
215226 contents = self .markup (str (object .__author__ ), self .preformat )
216- result = result + self .bigsection (
217- "Author" , "#ffffff" , "#7799ee" , contents )
227+ result = result + self .bigsection ("Author" , "#ffffff" , "#7799ee" , contents )
218228 if hasattr (object , "__credits__" ):
219229 contents = self .markup (str (object .__credits__ ), self .preformat )
220- result = result + self .bigsection (
221- "Credits" , "#ffffff" , "#7799ee" , contents )
230+ result = result + self .bigsection ("Credits" , "#ffffff" , "#7799ee" , contents )
222231
223232 return result
224233
225234 def classlink (self , object , modname ):
226235 """Make a link for a class."""
227236 name , module = object .__name__ , sys .modules .get (object .__module__ )
228237 if hasattr (module , name ) and getattr (module , name ) is object :
229- return "<a href=\" %s.html#%s\" >%s</a>" % (
230- module .__name__ , name , name
231- )
238+ return '<a href="%s.html#%s">%s</a>' % (module .__name__ , name , name )
232239 return pydoc .classname (object , modname )
233240
234241 def moduleSection (self , object , packageContext ):
@@ -269,11 +276,9 @@ def moduleSection(self, object, packageContext):
269276 self .modpkglink ((modname , name , ispackage , isshadowed ))
270277 )
271278 contents = string .join (items , "<br>" )
272- result = self .bigsection (
273- "Package Contents" , "#ffffff" , "#aa55cc" , contents )
279+ result = self .bigsection ("Package Contents" , "#ffffff" , "#aa55cc" , contents )
274280 elif modules :
275- result = self .bigsection (
276- "Modules" , "#fffff" , "#aa55cc" , contents )
281+ result = self .bigsection ("Modules" , "#fffff" , "#aa55cc" , contents )
277282 else :
278283 result = ""
279284 return result
@@ -309,10 +314,13 @@ class PackageDocumentationGenerator:
309314 """
310315
311316 def __init__ (
312- self , baseModules , destinationDirectory = "." ,
313- recursion = 1 , exclusions = (),
317+ self ,
318+ baseModules , # NOSONAR
319+ destinationDirectory = "." , # NOSONAR
320+ recursion = 1 ,
321+ exclusions = (),
314322 recursionStops = (),
315- formatter = None
323+ formatter = None ,
316324 ):
317325 """Initialize."""
318326 self .destinationDirectory = os .path .abspath (destinationDirectory )
@@ -329,8 +337,10 @@ def __init__(
329337 try :
330338 self .exclusions [exclusion ] = pydoc .locate (exclusion )
331339 except pydoc .ErrorDuringImport :
332- self .warn ("""Unable to import the module %s which was specified as an exclusion module""" %
333- (repr (exclusion )))
340+ self .warn (
341+ """Unable to import the module %s which was specified as an exclusion module"""
342+ % (repr (exclusion ))
343+ )
334344 self .formatter = formatter or DefaultFormatter ()
335345 for base in baseModules :
336346 self .addBase (base )
@@ -349,7 +359,10 @@ def addBase(self, specifier):
349359 self .baseSpecifiers [specifier ] = pydoc .locate (specifier )
350360 self .pending .append (specifier )
351361 except pydoc .ErrorDuringImport :
352- self .warn ("""Unable to import the module %s which was specified as a base module""" % (repr (specifier )))
362+ self .warn (
363+ """Unable to import the module %s which was specified as a base module"""
364+ % (repr (specifier ))
365+ )
353366
354367 def addInteresting (self , specifier ):
355368 """Add a module to the list of interesting modules."""
@@ -398,21 +411,27 @@ def process(self):
398411 pass
399412 except pydoc .ErrorDuringImport as value :
400413 self .info (""" ... FAILED %s""" % (repr (value )))
401- self .warn ("""Unable to import the module %s""" % (repr (self .pending [0 ])))
414+ self .warn (
415+ """Unable to import the module %s""" % (repr (self .pending [0 ])) # NOSONAR
416+ )
402417 except (SystemError , SystemExit ) as value :
403418 self .info (""" ... FAILED %s""" % (repr (value )))
404- self .warn ("""Unable to import the module %s""" % (repr (self .pending [0 ])))
419+ self .warn (
420+ """Unable to import the module %s""" % (repr (self .pending [0 ])) # NOSONAR
421+ )
405422 except Exception as value :
406423 self .info (""" ... FAILED %s""" % (repr (value )))
407- self .warn ("""Unable to import the module %s""" % (repr (self .pending [0 ])))
424+ self .warn (
425+ """Unable to import the module %s""" % (repr (self .pending [0 ])) # NOSONAR
426+ )
408427 else :
409428 page = self .formatter .page (
410429 pydoc .describe (object ),
411430 self .formatter .docmodule (
412431 object ,
413432 object .__name__ ,
414433 packageContext = self ,
415- )
434+ ),
416435 )
417436 file = open (
418437 os .path .join (
@@ -439,11 +458,9 @@ def clean(self, objectList, object):
439458 for key , value in objectList [:]:
440459 for excludeObject in self .exclusions .values ():
441460 if hasattr (excludeObject , key ) and excludeObject is not object :
442- if (
443- getattr (excludeObject , key ) is value or # noqa: W504
444- (hasattr (excludeObject , "__name__" ) and # noqa: W504
445- excludeObject .__name__ == "Numeric"
446- )
461+ if getattr (excludeObject , key ) is value or (
462+ hasattr (excludeObject , "__name__" )
463+ and excludeObject .__name__ == "Numeric"
447464 ):
448465 objectList [:] = [(k , o ) for k , o in objectList if k != key ]
449466
0 commit comments