diff --git a/papyri/gen.py b/papyri/gen.py index 44517883..87b60fac 100644 --- a/papyri/gen.py +++ b/papyri/gen.py @@ -48,7 +48,6 @@ from rich.logging import RichHandler from rich.progress import BarColumn, Progress, TextColumn, track from there import print as print_ -from velin.examples_section_utils import InOut, splitblank, splitcode from matplotlib import _pylab_helpers from .common_ast import Node @@ -88,10 +87,6 @@ ) from .vref import NumpyDocString -# delayed import - -from .myst_ast import MText - class ErrorCollector: def __init__(self, config: Config, log): @@ -999,7 +994,6 @@ def _normalize_see_also(see_also: Section, qa: str): return new_see_also - class PapyriDocTestRunner(doctest.DocTestRunner): def __init__(self, *args, gen, obj, qa, config, **kwargs): self.gen = gen @@ -1021,10 +1015,14 @@ def __init__(self, *args, gen, obj, qa, config, **kwargs): self.figs = [] self.fig_managers = _pylab_helpers.Gcf.get_all_fig_managers() - assert (len(self.fig_managers)) == 0, f"init fail in {self.qa} {len(self.fig_managers)}" + assert ( + len(self.fig_managers) + ) == 0, f"init fail in {self.qa} {len(self.fig_managers)}" def _get_tok_entries(self, example): - entries = parse_script(example.source, ns=self.globs, prev="", config=self.config, where=self.qa) + entries = parse_script( + example.source, ns=self.globs, prev="", config=self.config, where=self.qa + ) if entries is None: entries = [("jedi failed", "jedi failed")] entries = _add_classes(entries) @@ -1040,7 +1038,6 @@ def _figure_names(self): sha = sha256(pat.encode()).hexdigest()[:8] yield f"{pat}-{sha}.png" - def report_start(self, out, test, example): pass @@ -1058,9 +1055,7 @@ def report_success(self, out, test, example, got): wait_for_show = self.config.wait_for_plt_show self.fig_managers = _pylab_helpers.Gcf.get_all_fig_managers() figs = [] - if self.fig_managers and ( - ("plt.show" in example.source) or not wait_for_show - ): + if self.fig_managers and (("plt.show" in example.source) or not wait_for_show): for fig, figname in zip(self.fig_managers, figure_names): buf = io.BytesIO() fig.canvas.figure.savefig(buf, dpi=300) # , bbox_inches="tight" @@ -1091,6 +1086,7 @@ def report_failure(self, out, test, example, got): Code(tok_entries, got, ExecutionStatus.failure) ) + class Gen: """ Core class to generate docbundles for a given library. @@ -1232,7 +1228,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) import matplotlib.pyplot as plt if qa in config.exclude_jedi: @@ -1240,6 +1236,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") @@ -1266,7 +1263,6 @@ def dbg(*args): example_code, doctest_runner.globs, obj.__name__, filename, lineno ) - stdout = sys.stdout def debugprint(*args): diff --git a/requirements-dev.txt b/requirements-dev.txt index ef9c8106..b3c44218 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,7 +2,6 @@ pytest pytest-cov flit matplotlib -velin>=0.0.5 pytest-trio tree_sitter coverage diff --git a/requirements.txt b/requirements.txt index 792dc91d..2325653b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,4 +12,3 @@ rich there tree_sitter typer -velin