diff --git a/_unittests/ut__main/test_documentation_examples.py b/_unittests/ut__main/test_documentation_examples.py index 1791f08..e273fee 100644 --- a/_unittests/ut__main/test_documentation_examples.py +++ b/_unittests/ut__main/test_documentation_examples.py @@ -40,7 +40,7 @@ def run_test(self, fold: str, name: str, verbose=0) -> int: cmds = [sys.executable, "-u", os.path.join(fold, name)] p = subprocess.Popen(cmds, stdout=subprocess.PIPE, stderr=subprocess.PIPE) res = p.communicate() - out, err = res + _out, err = res st = err.decode("ascii", errors="ignore") if len(st) > 0 and "Traceback" in st: if '"dot" not found in path.' in st: diff --git a/_unittests/ut_blocdefs/test_blocref_extension.py b/_unittests/ut_blocdefs/test_blocref_extension.py index 9ebbd7e..e98dd82 100644 --- a/_unittests/ut_blocdefs/test_blocref_extension.py +++ b/_unittests/ut_blocdefs/test_blocref_extension.py @@ -20,9 +20,7 @@ def test_blocref_rst(self): this code should appear___ after - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html( @@ -61,9 +59,7 @@ def test_blocref_html(self): this code should appear___ after - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html( @@ -102,9 +98,7 @@ def test_blocref2(self): this code should appear___ after - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html( @@ -147,9 +141,7 @@ def test_blocreflist(self): :contents: 1 after - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html(content, writer_name="html") diff --git a/_unittests/ut_blocdefs/test_exref_extension.py b/_unittests/ut_blocdefs/test_exref_extension.py index 049b2a7..e724351 100644 --- a/_unittests/ut_blocdefs/test_exref_extension.py +++ b/_unittests/ut_blocdefs/test_exref_extension.py @@ -20,9 +20,7 @@ def test_exref(self): this code should appear___ after - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html( @@ -64,9 +62,7 @@ def test_exreflist(self): :sort: title after - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html(content, writer_name="rst") @@ -105,9 +101,7 @@ def test_exreflist_rst(self): :sort: title after - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') rst = rst2html(content, writer_name="rst") diff --git a/_unittests/ut_blocdefs/test_faqref_extension.py b/_unittests/ut_blocdefs/test_faqref_extension.py index eb247a1..3455c74 100644 --- a/_unittests/ut_blocdefs/test_faqref_extension.py +++ b/_unittests/ut_blocdefs/test_faqref_extension.py @@ -20,9 +20,7 @@ def test_faqref(self): this code should appear___ after - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html( @@ -64,9 +62,7 @@ def test_faqreflist(self): :sort: title after - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html(content, writer_name="rst") @@ -105,9 +101,7 @@ def test_faqreflist_rst(self): :sort: title after - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') rst = rst2html(content, writer_name="rst") diff --git a/_unittests/ut_blocdefs/test_mathdef_extension.py b/_unittests/ut_blocdefs/test_mathdef_extension.py index bcfc085..24cee62 100644 --- a/_unittests/ut_blocdefs/test_mathdef_extension.py +++ b/_unittests/ut_blocdefs/test_mathdef_extension.py @@ -20,9 +20,7 @@ def test_mathdef(self): this code should appear___ after - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html( @@ -62,9 +60,7 @@ def test_mathdeflist(self): :tag: definition after - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html(content, writer_name="rst") @@ -102,9 +98,7 @@ def test_mathdeflist_contents(self): :contents: after - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html(content, writer_name="rst") @@ -148,9 +142,7 @@ def test_mathdeflist_contents_body_sphinx(self): :contents: after - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html( diff --git a/_unittests/ut_collapse/test_collapse_extension.py b/_unittests/ut_collapse/test_collapse_extension.py index b7cb68a..2828af9 100644 --- a/_unittests/ut_collapse/test_collapse_extension.py +++ b/_unittests/ut_collapse/test_collapse_extension.py @@ -42,9 +42,7 @@ def test_collapse(self): this code should appear___ after - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') # RST @@ -101,9 +99,7 @@ def test_collapse_legend(self): this code should appear___ after - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') # RST @@ -136,9 +132,7 @@ def test_collapse_show(self): this code should appear___ after - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') # RST diff --git a/_unittests/ut_docassert/test_docassert.py b/_unittests/ut_docassert/test_docassert.py index e4af524..77fd152 100644 --- a/_unittests/ut_docassert/test_docassert.py +++ b/_unittests/ut_docassert/test_docassert.py @@ -13,7 +13,7 @@ def test_import_object(self): this = os.path.abspath(os.path.dirname(__file__)) data = os.path.join(this, "datadoc") with sys_path_append(data): - obj, name = import_object("exdocassert.onefunction", "function") + obj, _name = import_object("exdocassert.onefunction", "function") self.assertTrue(obj is not None) self.assertTrue(obj(4, 5), 9) @@ -45,7 +45,7 @@ def __len__(self): this = os.path.abspath(os.path.dirname(__file__)) data = os.path.join(this, "datadoc") with sys_path_append(data): - obj, name = import_object("exdocassert2.onefunction", "function") + _obj, _name = import_object("exdocassert2.onefunction", "function") newstring = ".. autofunction:: exdocassert2.onefunction" html, warn = rst2html(newstring, return_warnings=True) self.assertTrue(html is not None) @@ -88,7 +88,7 @@ def __len__(self): this = os.path.abspath(os.path.dirname(__file__)) data = os.path.join(this, "datadoc") with sys_path_append(data): - obj, name = import_object("exsig.clex.onemethod", "method") + _obj, _name = import_object("exsig.clex.onemethod", "method") newstring = ".. automethod:: exsig.clex.onemethod" html, warn = rst2html(newstring, return_warnings=True) self.assertTrue(html is not None) @@ -133,7 +133,7 @@ def __len__(self): this = os.path.abspath(os.path.dirname(__file__)) data = os.path.join(this, "datadoc") with sys_path_append(data): - obj, name = import_object("clsslk.Estimator", "class") + _obj, _name = import_object("clsslk.Estimator", "class") newstring = ".. autoclass:: clsslk.Estimator" html, warn = rst2html(newstring, return_warnings=True) self.assertTrue(html is not None) @@ -177,7 +177,7 @@ def __len__(self): this = os.path.abspath(os.path.dirname(__file__)) data = os.path.join(this, "datadoc") with sys_path_append(data): - obj, name = import_object("clsslk.Estimator2", "class") + _obj, _name = import_object("clsslk.Estimator2", "class") newstring = ".. autoclass:: clsslk.Estimator2" html, warn = rst2html(newstring, return_warnings=True) self.assertTrue(html is not None) @@ -221,7 +221,7 @@ def __len__(self): this = os.path.abspath(os.path.dirname(__file__)) data = os.path.join(this, "datadoc") with sys_path_append(data): - obj, name = import_object("clsslk.Estimator3", "class") + _obj, _name = import_object("clsslk.Estimator3", "class") newstring = ".. autoclass:: clsslk.Estimator3" html, warn = rst2html( newstring, return_warnings=True, new_extensions=["numpydoc"] diff --git a/_unittests/ut_epkg/test_epkg_extension.py b/_unittests/ut_epkg/test_epkg_extension.py index 31876a5..a741796 100644 --- a/_unittests/ut_epkg/test_epkg_extension.py +++ b/_unittests/ut_epkg/test_epkg_extension.py @@ -8,7 +8,6 @@ depart_epkg_node, ) - tives = [("epkg", epkg_role, epkg_node, visit_epkg_node, depart_epkg_node)] @@ -20,9 +19,7 @@ def test_epkg_module(self): ================ abeforea :epkg:`pandas` aaftera - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html(content, writer_name="rst") @@ -47,9 +44,7 @@ def test_epkg_module_twice(self): ================ abeforea :epkg:`pandas` aaftera - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html(content, writer_name="rst") @@ -62,9 +57,7 @@ def test_epkg_sub(self): ================ abeforea :epkg:`pandas:DataFrame.to_html` aaftera - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html(content, writer_name="html") @@ -90,9 +83,7 @@ def test_epkg_function(self): ================ abeforea :epkg:`pandas:DataFrame:to_html` aaftera - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') def pandas_link(input): @@ -129,9 +120,7 @@ def test_epkg_class(self): abeforea :epkg:`pandas:DataFrame:to_html` aaftera 7za :epkg:`Pandoc` 7zb - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') class pandas_link: @@ -153,9 +142,7 @@ def test_epkg_function_string(self): ================ abeforea :epkg:`pandas:DataFrame:to_html` aaftera - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html(content, writer_name="html") @@ -188,9 +175,7 @@ def test_epkg_function_long_link(self): `one link on two lines `_. - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html(content, writer_name="html") diff --git a/_unittests/ut_gdot/test_gdot_extension.py b/_unittests/ut_gdot/test_gdot_extension.py index 28afff4..39bee87 100644 --- a/_unittests/ut_gdot/test_gdot_extension.py +++ b/_unittests/ut_gdot/test_gdot_extension.py @@ -22,9 +22,7 @@ def test_gdot1(self): } after - """.replace( - " ", "" - ) + """.replace(" ", "") content = rst2html( content, writer_name="rst", new_extensions=["sphinx_runpython.gdot"] @@ -44,9 +42,7 @@ def test_gdot2(self): print('''digraph foo { HbarH -> HbazH; }'''.replace("H", '"')) after - """.replace( - " ", "" - ) + """.replace(" ", "") content = rst2html( content, writer_name="rst", new_extensions=["sphinx_runpython.gdot"] @@ -64,9 +60,7 @@ def test_gdot2_split(self): print('''...BEGINdigraph foo { HbarH -> HbazH; }'''.replace("H", '"')) after - """.replace( - " ", "" - ) + """.replace(" ", "") content = rst2html( content, writer_name="rst", new_extensions=["sphinx_runpython.gdot"] @@ -87,9 +81,7 @@ def test_gdot3_svg(self): } after - """.replace( - " ", "" - ) + """.replace(" ", "") content = rst2html( content, writer_name="html", new_extensions=["sphinx_runpython.gdot"] @@ -111,9 +103,7 @@ def test_gdot3_svg_process(self): } after - """.replace( - " ", "" - ) + """.replace(" ", "") content = rst2html( content, writer_name="html", new_extensions=["sphinx_runpython.gdot"] @@ -135,9 +125,7 @@ def test_gdot4_png(self): } after - """.replace( - " ", "" - ) + """.replace(" ", "") try: content = rst2html( diff --git a/_unittests/ut_quote/test_quote_extension.py b/_unittests/ut_quote/test_quote_extension.py index b49db17..d331172 100644 --- a/_unittests/ut_quote/test_quote_extension.py +++ b/_unittests/ut_quote/test_quote_extension.py @@ -16,9 +16,7 @@ def test_quote(self): this code should appear___ next - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html( @@ -71,9 +69,7 @@ def test_quote_manga(self): this code should appear___ next - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html( @@ -126,9 +122,7 @@ def test_quote_film(self): this code should appear___ next - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html( @@ -182,9 +176,7 @@ def test_quote_show(self): this code should appear___ next - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html( @@ -238,9 +230,7 @@ def test_quote_comic(self): this code should appear___ next - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html( @@ -294,9 +284,7 @@ def test_quote_disc(self): this code should appear___ next - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html( @@ -350,9 +338,7 @@ def test_quote_ado(self): this code should appear___ next - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html( @@ -406,9 +392,7 @@ def test_quote_child(self): this code should appear___ next - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html( diff --git a/_unittests/ut_runpython/test_run_cmd_timeout.py b/_unittests/ut_runpython/test_run_cmd_timeout.py index 916806e..8a66bc0 100644 --- a/_unittests/ut_runpython/test_run_cmd_timeout.py +++ b/_unittests/ut_runpython/test_run_cmd_timeout.py @@ -7,7 +7,7 @@ class TestRunCmdTimeout(ExtTestCase): def test_run_cmd_timeout(self): if __name__ == "__main__": cmd = "more" - out, err = run_cmd( + _out, err = run_cmd( cmd, wait=True, tell_if_no_output=1, communicate=False, timeout=3 ) self.assertIn("Process killed", err) diff --git a/_unittests/ut_runpython/test_runpython_code_block.py b/_unittests/ut_runpython/test_runpython_code_block.py index cab5078..5260a5e 100644 --- a/_unittests/ut_runpython/test_runpython_code_block.py +++ b/_unittests/ut_runpython/test_runpython_code_block.py @@ -27,9 +27,7 @@ def test_code_block(self): ens = ["f", 0] for j in ens: print(j) - """.replace( - " ", "" - ) + """.replace(" ", "") rst = rst2html(content, writer_name="rst") self.assertIn("csharp", str(rst)) @@ -55,9 +53,7 @@ class runpythonthis_node(nodes.Structural, nodes.Element): { return x.ToInt(); } - """.replace( - " ", "" - ) + """.replace(" ", "") rst = rst2html(content, writer_name="rst") self.assertIn(".. code-block:: csharp", rst) diff --git a/_unittests/ut_runpython/test_runpython_context.py b/_unittests/ut_runpython/test_runpython_context.py index 3331e35..ae61d71 100644 --- a/_unittests/ut_runpython/test_runpython_context.py +++ b/_unittests/ut_runpython/test_runpython_context.py @@ -40,9 +40,7 @@ def depart_rp_node(self, node): print("failed") for k, v in sorted(locals().copy().items()): print(k, "=", [v]) - """.replace( - " ", "" - ) + """.replace(" ", "") rst = rst2html(content, writer_name="rst") self.assertIn("restored saved for later", rst) diff --git a/_unittests/ut_runpython/test_runpython_extension.py b/_unittests/ut_runpython/test_runpython_extension.py index cbaef02..99d9a77 100644 --- a/_unittests/ut_runpython/test_runpython_extension.py +++ b/_unittests/ut_runpython/test_runpython_extension.py @@ -60,9 +60,7 @@ def depart_rp_node(self, node): print(u"setsysvar: " + str( sys.__dict__.get( 'enable_disabled_documented_pieces_of_code', None))) - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html(content, writer_name="html") @@ -101,9 +99,7 @@ def test_runpython_numpy(self): import numpy print(numpy.array([1.123456789, 1.987654321])) - """.replace( - " ", "" - ) + """.replace(" ", "") html = rst2html(content, writer_name="rst") if "[1.12 1.99]" not in html: @@ -129,9 +125,7 @@ def test_runpython_numpy_linenos(self): import numpy print(numpy.array([1.123456789, 1.987654321])) - """.replace( - " ", "" - ) + """.replace(" ", "") html = rst2html(content, writer_name="rst") if "[1.12 1.99]" not in html: @@ -174,9 +168,7 @@ def depart_rp_node(self, node): import warnings warnings.warn("deprecated", DeprecationWarning) - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html(content, writer_name="rst") @@ -217,9 +209,7 @@ def depart_rp_node(self, node): import warnings warnings.warn("deprecated", DeprecationWarning) - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html(content, writer_name="rst") @@ -260,9 +250,7 @@ def depart_rp_node(self, node): import sys print(u"setsysvar: " + str(sys.__dict__.get( 'enable_disabled_documented_pieces_of_code', None))) - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html(content, writer_name="rst") @@ -319,9 +307,7 @@ def depart_rp_node(self, node): import sys print(u"setsysvar: " + str(sys.__dict__.get( 'enable_disabled_documented_pieces_of_code', None))) - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html(content, writer_name="html") @@ -372,9 +358,7 @@ def depart_rp_node(self, node): print(u"this code should" + u" appear") z = 1/0 print(u"this one should" + u" not") - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html(content, writer_name="html") @@ -417,9 +401,7 @@ def depart_rp_node(self, node): print(u"this code should" + u" appear") z = 0.5 + 0.6 print(u"this one should" + u" not") - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html(content, writer_name="html") @@ -440,9 +422,7 @@ def depart_rp_node(self, node): :assert: z == 1.2 z = 0.5 + 0.6 - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') try: @@ -485,9 +465,7 @@ def depart_rp_node(self, node): print(u"this code should" + u" appear") z = 1/0 print(u"this one should" + u" not") - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') html = rst2html(content, writer_name="html") diff --git a/_unittests/ut_runpython/test_runpython_extension_image.py b/_unittests/ut_runpython/test_runpython_extension_image.py index 6cb09d6..9b5609a 100644 --- a/_unittests/ut_runpython/test_runpython_extension_image.py +++ b/_unittests/ut_runpython/test_runpython_extension_image.py @@ -51,9 +51,7 @@ def depart_rp_node(self, node): text = ".. image:: oo.png\\n :width: 200px" print(text) - """.replace( - " ", "" - ).replace( + """.replace(" ", "").replace( "__FOLD__", temp.replace("\\", "/") ) content = content.replace('u"', '"') diff --git a/_unittests/ut_runpython/test_runpython_extension_toggle.py b/_unittests/ut_runpython/test_runpython_extension_toggle.py index 49ba8a5..b4351e9 100644 --- a/_unittests/ut_runpython/test_runpython_extension_toggle.py +++ b/_unittests/ut_runpython/test_runpython_extension_toggle.py @@ -54,9 +54,7 @@ def depart_rp_node(self, node): print(u"setsysvar: " + str( sys.__dict__.get( 'enable_disabled_documented_pieces_of_code', None))) - """.replace( - " ", "" - ) + """.replace(" ", "") content = content.replace('u"', '"') # HTML diff --git a/_unittests/ut_runpython/test_runpython_store_in_file.py b/_unittests/ut_runpython/test_runpython_store_in_file.py index e24574e..49cd411 100644 --- a/_unittests/ut_runpython/test_runpython_store_in_file.py +++ b/_unittests/ut_runpython/test_runpython_store_in_file.py @@ -39,9 +39,7 @@ def fctfct(): print("***********") print(code) print("***********") - """.replace( - " ", "" - ) + """.replace(" ", "") temp = os.path.abspath(os.path.dirname(__file__)) dest = os.path.join(temp, "exescript.py") diff --git a/pyproject.toml b/pyproject.toml index 7c9290c..34ddfac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,12 +40,13 @@ select = [ [tool.ruff.lint.extend-per-file-ignores] "**" = [ + "B905", "C401", "C408", "C413", "PIE790", "PYI041", "RUF012", "RUF100", "RUF010", "SIM108", "SIM102", "SIM114", "SIM103", "SIM910", - "UP006", "UP015", "UP027", "UP031", "UP034", "UP035", "UP032" + "UP006", "UP007", "UP015", "UP027", "UP031", "UP034", "UP035", "UP032", "UP045" ] "_doc/examples/plot_*.py" = ["E402", "B018", "PIE808", "SIM105", "SIM117"] "_doc/notebooks/plot_*.py" = ["E402", "B018", "PIE808", "SIM105", "SIM117"] diff --git a/sphinx_runpython/collapse/sphinx_collapse_extension.py b/sphinx_runpython/collapse/sphinx_collapse_extension.py index d55eafb..ff03380 100644 --- a/sphinx_runpython/collapse/sphinx_collapse_extension.py +++ b/sphinx_runpython/collapse/sphinx_collapse_extension.py @@ -126,9 +126,7 @@ def visit_collapse_node_html(self, node): x.style.display = "block"; b.innerText = '__HIDE__'; } else { x.style.display = "none"; b.innerText = '__UNHIDE__'; } - }""".replace( - " ", "" - ) + }""".replace(" ", "") script = script.replace("__ID__", nid) script = script.replace("__HIDE__", hide) script = script.replace("__UNHIDE__", unhide) diff --git a/sphinx_runpython/ext_io_helper.py b/sphinx_runpython/ext_io_helper.py index beabc7f..a287f3e 100644 --- a/sphinx_runpython/ext_io_helper.py +++ b/sphinx_runpython/ext_io_helper.py @@ -3,7 +3,6 @@ import os import re import shutil -import socket import time import warnings import http.client as http_client @@ -368,7 +367,7 @@ def _local_loop(ur): urllib_error.HTTPError, urllib_error.URLError, ConnectionRefusedError, - socket.timeout, + TimeoutError, ConnectionResetError, http_client.BadStatusLine, http_client.IncompleteRead, diff --git a/sphinx_runpython/gdot/sphinx_gdot_extension.py b/sphinx_runpython/gdot/sphinx_gdot_extension.py index 2692745..f527be1 100644 --- a/sphinx_runpython/gdot/sphinx_gdot_extension.py +++ b/sphinx_runpython/gdot/sphinx_gdot_extension.py @@ -217,17 +217,13 @@ def process(text): content = """
- """.format( - nid - ) + """.format(nid) script = ( """ require(['__URL__'], function() { var svgGraph = Viz("__DOT__"); document.getElementById('gdot-__ID__').innerHTML = svgGraph; }); - """.replace( - "__ID__", nid - ) + """.replace("__ID__", nid) .replace("__DOT__", process(node["code"])) .replace("__URL__", node["url"]) ) diff --git a/sphinx_runpython/runpython/run_cmd.py b/sphinx_runpython/runpython/run_cmd.py index bb0fc31..ca2323e 100644 --- a/sphinx_runpython/runpython/run_cmd.py +++ b/sphinx_runpython/runpython/run_cmd.py @@ -281,10 +281,10 @@ def run_cmd( begin = time.perf_counter() last_update = begin # with threads - (stdoutReader, stdoutQueue) = _AsyncLineReader.getForFd( + stdoutReader, stdoutQueue = _AsyncLineReader.getForFd( stdout, catch_exit=catch_exit ) - (stderrReader, stderrQueue) = _AsyncLineReader.getForFd( + stderrReader, stderrQueue = _AsyncLineReader.getForFd( stderr, catch_exit=catch_exit ) runloop = True diff --git a/sphinx_runpython/tools/sphinx_api.py b/sphinx_runpython/tools/sphinx_api.py index f5fb7fa..603890e 100644 --- a/sphinx_runpython/tools/sphinx_api.py +++ b/sphinx_runpython/tools/sphinx_api.py @@ -13,23 +13,19 @@ def _write_doc_folder( """ Creates all the file in a dictionary. """ - template = textwrap.dedent( - """ + template = textwrap.dedent(""" .. automodule:: :members: :no-undoc-members: - """ - ) + """) - index = textwrap.dedent( - """ + index = textwrap.dedent(""" - """ - ) + """) submodule = ".".join(os.path.splitext(folder)[0].replace("\\", "/").split("/")) fullsubmodule = f"{prefix}.{submodule}" if prefix else submodule @@ -39,16 +35,12 @@ def _write_doc_folder( .replace("", "=" * len(fullsubmodule)), ] if subfolders: - rows.append( - textwrap.dedent( - """ + rows.append(textwrap.dedent(""" .. toctree:: :maxdepth: 1 :caption: submodules - """ - ) - ) + """)) for sub in subfolders: rows.append(f" {sub}/index") res = {} @@ -75,29 +67,21 @@ def _write_doc_folder( res[key] = text if not has_module: has_module = True - rows.append( - textwrap.dedent( - """ + rows.append(textwrap.dedent(""" .. toctree:: :maxdepth: 1 :caption: modules - """ - ) - ) + """)) rows.append(f" {last}") - rows.append( - textwrap.dedent( - f""" + rows.append(textwrap.dedent(f""" .. automodule:: {submodule} :members: :no-undoc-members: - """ - ) - ) + """)) res["index.rst"] = "\n".join(rows) return res @@ -121,7 +105,7 @@ def sphinx_api( :return: list of written file """ folder = folder.rstrip("/\\") - root, package_name = os.path.split(folder) + root, _package_name = os.path.split(folder) files = [] if verbose: print(f"[sphinx_api] start creating API for {folder!r}")