Skip to content

Commit 1efadf7

Browse files
authored
maint: use findall instead of traverse (#585)
* maint: use findall * fix: add pyarrow test dep * fix: remove deprecated code * chore: update tests for new pins * chore: pin pandas
1 parent c3e015e commit 1efadf7

8 files changed

Lines changed: 11 additions & 8 deletions

myst_nb/docutils_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def _parse(self, inputstring: str, document: nodes.document) -> None:
207207
css_paths.append(
208208
nb_renderer.write_file(
209209
["mystnb.css"],
210-
import_resources.read_binary(static, "mystnb.css"),
210+
(import_resources.files(static) / "mystnb.css").read_bytes(),
211211
overwrite=True,
212212
)
213213
)

myst_nb/ext/execution_tables.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from sphinx.util import logging
1818
from sphinx.util.docutils import SphinxDirective
1919

20+
from myst_nb._compat import findall
2021
from myst_nb.sphinx_ import NbMetadataCollector, SphinxEnvType
2122

2223
SPHINX_LOGGER = logging.getLogger(__name__)
@@ -76,7 +77,7 @@ class ExecutionStatsPostTransform(SphinxPostTransform):
7677
def run(self, **kwargs) -> None:
7778
"""Replace the placeholder node with the final table nodes."""
7879
self.env: SphinxEnvType
79-
for node in self.document.traverse(ExecutionStatsNode):
80+
for node in findall(self.document)(ExecutionStatsNode):
8081
node.replace_self(
8182
make_stat_table(
8283
self.env.docname, NbMetadataCollector.get_doc_data(self.env)

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ testing = [
101101
"matplotlib==3.7.*",
102102
"nbdime",
103103
"numpy",
104-
"pandas",
104+
"pandas==1.5.*",
105+
"pyarrow",
105106
"pytest~=7.1",
106107
"pytest-cov>=3,<5",
107108
"pytest-regressions",

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ def _check_nbs(obtained_filename, expected_filename):
248248
def clean_doctree():
249249
def _func(doctree):
250250
if os.name == "nt": # on Windows file paths are absolute
251-
for node in doctree.traverse(image_node): # type: image_node
251+
findall = getattr(doctree, "findall", doctree.traverse)
252+
for node in findall(image_node): # type: image_node
252253
if "candidates" in node:
253254
node["candidates"]["*"] = (
254255
"_build/jupyter_execute/"

tests/test_execute/test_complex_outputs_unrun_auto.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@
214214
(√5⋅ⅈ) ⋅⎜─ - ──────⎟ + (-√5⋅ⅈ) ⋅⎜─ + ──────⎟
215215
⎝2 5 ⎠ ⎝2 5 ⎠
216216
<container mime_type="image/png">
217-
<image candidates="{'*': '_build/jupyter_execute/a04ee1a78ad33a6345469c5f6d84ff6ef0bfcb4d9e3a8d10eaa7ea3f445bbc5c.png'}" uri="_build/jupyter_execute/a04ee1a78ad33a6345469c5f6d84ff6ef0bfcb4d9e3a8d10eaa7ea3f445bbc5c.png">
217+
<image candidates="{'*': '_build/jupyter_execute/9bc81205a14646a235d284d1b68223d17f30f7f1d3d8ed3e52cf47830b02e3bb.png'}" uri="_build/jupyter_execute/9bc81205a14646a235d284d1b68223d17f30f7f1d3d8ed3e52cf47830b02e3bb.png">
218218
<container mime_type="text/latex">
219219
<math_block classes="output text_latex" nowrap="False" number="True" xml:space="preserve">
220220
\displaystyle \left(\sqrt{5} i\right)^{\alpha} \left(\frac{1}{2} - \frac{2 \sqrt{5} i}{5}\right) + \left(- \sqrt{5} i\right)^{\alpha} \left(\frac{1}{2} + \frac{2 \sqrt{5} i}{5}\right)

tests/test_execute/test_complex_outputs_unrun_cache.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@
214214
(√5⋅ⅈ) ⋅⎜─ - ──────⎟ + (-√5⋅ⅈ) ⋅⎜─ + ──────⎟
215215
⎝2 5 ⎠ ⎝2 5 ⎠
216216
<container mime_type="image/png">
217-
<image candidates="{'*': '_build/jupyter_execute/a04ee1a78ad33a6345469c5f6d84ff6ef0bfcb4d9e3a8d10eaa7ea3f445bbc5c.png'}" uri="_build/jupyter_execute/a04ee1a78ad33a6345469c5f6d84ff6ef0bfcb4d9e3a8d10eaa7ea3f445bbc5c.png">
217+
<image candidates="{'*': '_build/jupyter_execute/9bc81205a14646a235d284d1b68223d17f30f7f1d3d8ed3e52cf47830b02e3bb.png'}" uri="_build/jupyter_execute/9bc81205a14646a235d284d1b68223d17f30f7f1d3d8ed3e52cf47830b02e3bb.png">
218218
<container mime_type="text/latex">
219219
<math_block classes="output text_latex" nowrap="False" number="True" xml:space="preserve">
220220
\displaystyle \left(\sqrt{5} i\right)^{\alpha} \left(\frac{1}{2} - \frac{2 \sqrt{5} i}{5}\right) + \left(- \sqrt{5} i\right)^{\alpha} \left(\frac{1}{2} + \frac{2 \sqrt{5} i}{5}\right)

tests/test_execute/test_custom_convert_auto.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
<literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve">
1919
<Figure size 640x480 with 1 Axes>
2020
<container mime_type="image/png">
21-
<image candidates="{'*': '_build/jupyter_execute/79c62be209810029709c370dc93d2e5dba383561eb0d8bc1ce8b30db61641985.png'}" uri="_build/jupyter_execute/79c62be209810029709c370dc93d2e5dba383561eb0d8bc1ce8b30db61641985.png">
21+
<image candidates="{'*': '_build/jupyter_execute/a2e637020dfe58f670ba2c942d7a55e49ba48bed09312569ee15a84f5ac680cb.png'}" uri="_build/jupyter_execute/a2e637020dfe58f670ba2c942d7a55e49ba48bed09312569ee15a84f5ac680cb.png">

tests/test_execute/test_custom_convert_cache.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
<literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve">
1919
<Figure size 640x480 with 1 Axes>
2020
<container mime_type="image/png">
21-
<image candidates="{'*': '_build/jupyter_execute/79c62be209810029709c370dc93d2e5dba383561eb0d8bc1ce8b30db61641985.png'}" uri="_build/jupyter_execute/79c62be209810029709c370dc93d2e5dba383561eb0d8bc1ce8b30db61641985.png">
21+
<image candidates="{'*': '_build/jupyter_execute/a2e637020dfe58f670ba2c942d7a55e49ba48bed09312569ee15a84f5ac680cb.png'}" uri="_build/jupyter_execute/a2e637020dfe58f670ba2c942d7a55e49ba48bed09312569ee15a84f5ac680cb.png">

0 commit comments

Comments
 (0)