Skip to content

Commit

Permalink
maint: use findall
Browse files Browse the repository at this point in the history
  • Loading branch information
agoose77 committed Feb 22, 2024
1 parent c3e015e commit 2660779
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion myst_nb/ext/execution_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from sphinx.util import logging
from sphinx.util.docutils import SphinxDirective

from myst_nb._compat import findall
from myst_nb.sphinx_ import NbMetadataCollector, SphinxEnvType

SPHINX_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -76,7 +77,7 @@ class ExecutionStatsPostTransform(SphinxPostTransform):
def run(self, **kwargs) -> None:
"""Replace the placeholder node with the final table nodes."""
self.env: SphinxEnvType
for node in self.document.traverse(ExecutionStatsNode):
for node in findall(self.document)(ExecutionStatsNode):
node.replace_self(
make_stat_table(
self.env.docname, NbMetadataCollector.get_doc_data(self.env)
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ def _check_nbs(obtained_filename, expected_filename):
def clean_doctree():
def _func(doctree):
if os.name == "nt": # on Windows file paths are absolute
for node in doctree.traverse(image_node): # type: image_node
findall = getattr(doctree, "findall", doctree.traverse)
for node in findall(image_node): # type: image_node
if "candidates" in node:
node["candidates"]["*"] = (
"_build/jupyter_execute/"
Expand Down

0 comments on commit 2660779

Please sign in to comment.