Skip to content

Commit 5c6eb36

Browse files
authored
Please black (doc directory). (#897)
1 parent d79c9c6 commit 5c6eb36

File tree

5 files changed

+85
-59
lines changed

5 files changed

+85
-59
lines changed

doc/api/epydoc/build.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
pkg_resources.require("epydoc")
1515

1616
from epydoc.cli import cli # pylint: disable=import-error
17+
1718
sys.argv = """epydoc.py pymodbus
1819
--html --simple-term --quiet
1920
--include-log

doc/api/pydoc/build.py

Lines changed: 56 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -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):
98101
class 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

doc/api/pydoctor/build.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
import os
1010
import shutil
1111
import pkg_resources
12+
1213
pkg_resources.require("pydoctor")
1314

1415
from pydoctor.driver import main # pylint: disable=import-error
16+
1517
sys.argv = """pydoctor.py --quiet
1618
--project-name=Pymodbus
1719
--project-url=http://code.google.com/p/pymodbus/

doc/conf.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import sys
2222
from recommonmark.transform import AutoStructify
2323
from pymodbus import __version__
24+
2425
parent_dir = os.path.abspath(os.pardir)
2526
# examples = os.path.join(parent_dir, "examples")
2627
example_contrib = os.path.join(parent_dir, "examples/contrib")
@@ -45,7 +46,6 @@
4546
# extensions coming with Sphinx (named "sphinx.ext.*") or your custom
4647
# ones.
4748

48-
# extensions = ["sphinx.ext.autodoc", "m2r", "recommonmark"]
4949
extensions = ["sphinx.ext.autodoc", "m2r2"]
5050

5151
# Add any paths that contain templates here, relative to this directory.
@@ -59,7 +59,6 @@
5959
# }
6060

6161
source_suffix = [".rst", ".md"]
62-
# source_suffix = ".rst"
6362

6463
# The master toctree document.
6564
master_doc = "index" # pylint: disable=invalid-name
@@ -141,15 +140,12 @@
141140
# The paper size ("letterpaper" or "a4paper").
142141
#
143142
# "papersize": "letterpaper",
144-
145143
# The font size ("10pt", "11pt" or "12pt").
146144
#
147145
# "pointsize": "10pt",
148-
149146
# Additional stuff for the LaTeX preamble.
150147
#
151148
# "preamble": "",
152-
153149
# Latex figure (float) alignment
154150
#
155151
# "figure_align": "htbp",
@@ -159,19 +155,21 @@
159155
# (source start file, target name, title,
160156
# author, documentclass [howto, manual, or own class]).
161157
latex_documents = [ # NOSONAR
162-
(master_doc, "PyModbus.tex", "PyModbus Documentation", # NOSONAR
163-
"Sanjay", "manual"),
158+
(
159+
master_doc,
160+
"PyModbus.tex",
161+
"PyModbus Documentation", # NOSONAR
162+
"Sanjay",
163+
"manual",
164+
),
164165
]
165166

166167

167168
# -- Options for manual page output ---------------------------------------
168169

169170
# One entry per manual page. List of tuples
170171
# (source start file, name, description, authors, manual section).
171-
man_pages = [
172-
(master_doc, "pymodbus", "PyModbus Documentation",
173-
[author], 1)
174-
]
172+
man_pages = [(master_doc, "pymodbus", "PyModbus Documentation", [author], 1)]
175173

176174

177175
# -- Options for Texinfo output -------------------------------------------
@@ -180,18 +178,26 @@
180178
# (source start file, target name, title, author,
181179
# dir menu entry, description, category)
182180
texinfo_documents = [
183-
(master_doc, "PyModbus", "PyModbus Documentation",
184-
author, "PyModbus", "One line description of project.",
185-
"Miscellaneous"),
181+
(
182+
master_doc,
183+
"PyModbus",
184+
"PyModbus Documentation",
185+
author,
186+
"PyModbus",
187+
"One line description of project.",
188+
"Miscellaneous",
189+
),
186190
]
187191

188192

189193
def setup(app):
190194
"""Do setup."""
191-
app.add_config_value("recommonmark_config", {
192-
"url_resolver": lambda url: github_doc_root + url,
193-
"auto_toc_tree_section": "Contents",
194-
},
195-
True
195+
app.add_config_value(
196+
"recommonmark_config",
197+
{
198+
"url_resolver": lambda url: github_doc_root + url,
199+
"auto_toc_tree_section": "Contents",
200+
},
201+
True,
196202
)
197203
app.add_transform(AutoStructify)

examples/common/async_asyncio_serial_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ async def start_async_test(client): # pylint: disable=redefined-outer-name
127127
# ----------------------------------------------------------------------- #
128128
# socat -d -d PTY,link=/tmp/ptyp0,raw,echo=0,ispeed=9600 PTY,
129129
# link=/tmp/ttyp0,raw,echo=0,ospeed=9600
130-
loop, client = ModbusClient(schedulers.ASYNC_IO, port="/tmp/ttyp0", # nosec pylint: disable=unpacking-non-sequence
130+
loop, client = ModbusClient(schedulers.ASYNC_IO, port="/tmp/ttyp0", # NOSONAR # nosec pylint: disable=unpacking-non-sequence
131131
baudrate=9600, method="rtu")
132132
loop.run_until_complete(start_async_test(client.protocol))
133133
loop.close()

0 commit comments

Comments
 (0)