Skip to content

Commit

Permalink
reforamt to please linters
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Dec 16, 2023
1 parent a1c8cdb commit db1dbb4
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions papyri/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
if True:
from .myst_ast import MText


class ErrorCollector:
_expected_unseen: Dict[str, Any]
errored: bool
Expand Down Expand Up @@ -1292,7 +1293,7 @@ def get_example_data(
The capturing of matplotlib figures is also limited.
"""
assert qa is not None
example_code = '\n'.join(example_section)
example_code = "\n".join(example_section)
blocks = example_code.split("\n\n")
import matplotlib.pyplot as plt

Expand All @@ -1301,6 +1302,7 @@ def get_example_data(
log.debug(f"Turning off type inference for func {qa!r}")

sys_stdout = sys.stdout

def dbg(*args):
for arg in args:
sys_stdout.write(f"{arg}\n")
Expand All @@ -1315,22 +1317,26 @@ def dbg(*args):
except (TypeError, OSError):
lineno = None

doctest_runner = PapyriDocTestRunner(gen=self, obj=obj, qa=qa,
config=config,
# TODO: Make optionflags configurable
optionflags=doctest.ELLIPSIS)
doctest_runner = PapyriDocTestRunner(
gen=self,
obj=obj,
qa=qa,
config=config,
# TODO: Make optionflags configurable
optionflags=doctest.ELLIPSIS,
)
example_section_data = Section([], None)

def debugprint(*args):
"""
version of print that capture current stdout to use during testing to debug
"""
sys_stdout.write(" ".join(str(x) for x in args) + "\n")

for block in blocks:
doctests = doctest.DocTestParser().get_doctest(block,
doctest_runner.globs,
obj.__name__, filename,
lineno)
doctests = doctest.DocTestParser().get_doctest(
block, doctest_runner.globs, obj.__name__, filename, lineno
)
if config.exec and doctests.examples:
doctest_runner.run(doctests, out=debugprint)
example_section_data.extend(doctest_runner.example_section_data)
Expand Down

0 comments on commit db1dbb4

Please sign in to comment.