Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Nov 20, 2023
1 parent 9ae4faf commit db80dd1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
24 changes: 10 additions & 14 deletions papyri/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -88,10 +87,6 @@
)
from .vref import NumpyDocString

# delayed import

from .myst_ast import MText


class ErrorCollector:
def __init__(self, config: Config, log):
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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

Expand All @@ -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"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -1232,14 +1228,15 @@ 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:
config = config.replace(infer=False)
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 @@ -1266,7 +1263,6 @@ def dbg(*args):
example_code, doctest_runner.globs, obj.__name__, filename, lineno
)


stdout = sys.stdout

def debugprint(*args):
Expand Down
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ pytest
pytest-cov
flit
matplotlib
velin>=0.0.5
pytest-trio
tree_sitter
coverage
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ rich
there
tree_sitter
typer
velin

0 comments on commit db80dd1

Please sign in to comment.