Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: no-wrap KeyError for docutils math_block #13312

Closed
bsipocz opened this issue Feb 7, 2025 · 3 comments · Fixed by #13323
Closed

BUG: no-wrap KeyError for docutils math_block #13312

bsipocz opened this issue Feb 7, 2025 · 3 comments · Fixed by #13323

Comments

@bsipocz
Copy link
Contributor

bsipocz commented Feb 7, 2025

Describe the bug

I suspect the rename PR in #13264 has some unintended consequences. We started seeing this following KeyError error in the CI for MyST-NB:

________________________________________________________________________ test_complex_outputs _________________________________________________________________________

sphinx_run = <conftest.SphinxFixture object at 0x13109f5f0>, clean_doctree = <function clean_doctree.<locals>._func at 0x13066d8a0>
file_regression = <conftest.FileRegression object at 0x131542e40>

    @pytest.mark.sphinx_params("complex_outputs.ipynb", conf={"nb_execution_mode": "off"})
    def test_complex_outputs(sphinx_run, clean_doctree, file_regression):
>       sphinx_run.build()

/Users/bsipocz/munka/devel/executablebooks/MyST-NB/tests/test_render_outputs.py:50: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/Users/bsipocz/munka/devel/executablebooks/MyST-NB/tests/conftest.py:85: in build
    self.app.build()
/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/sphinx/testing/util.py:239: in build
    super().build(force_all, filenames)
/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/sphinx/application.py:428: in build
    self.builder.build_update()
/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/sphinx/builders/__init__.py:372: in build_update
    self.build(
/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/sphinx/builders/__init__.py:451: in build
    self.write(docnames, updated_docnames, method)
/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/sphinx/builders/__init__.py:732: in write
    self.write_documents(docnames)
/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/sphinx/builders/__init__.py:746: in write_documents
    self._write_serial(sorted_docnames)
/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/sphinx/builders/__init__.py:765: in _write_serial
    self.write_doc(docname, doctree)
/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/sphinx/builders/html/__init__.py:669: in write_doc
    self.docwriter.write(doctree, destination)
/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/docutils/writers/__init__.py:80: in write
    self.translate()
/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/sphinx/writers/html.py:36: in translate
    self.document.walkabout(visitor)
/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/docutils/nodes.py:186: in walkabout
    if child.walkabout(visitor):
/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/docutils/nodes.py:186: in walkabout
    if child.walkabout(visitor):
/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/docutils/nodes.py:186: in walkabout
    if child.walkabout(visitor):
/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/docutils/nodes.py:186: in walkabout
    if child.walkabout(visitor):
/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/docutils/nodes.py:178: in walkabout
    visitor.dispatch_visit(self)
/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/sphinx/util/docutils.py:767: in dispatch_visit
    method(node)
/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/sphinx/writers/html5.py:1004: in visit_math_block
    visit(self, node)
/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/sphinx/ext/mathjax.py:50: in html_visit_displaymath
    if node['no-wrap']:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <math_block: <#text: ' a = b+c '>>, key = 'no-wrap'

    def __getitem__(self, key):
        if isinstance(key, str):
>           return self.attributes[key]
E           KeyError: 'no-wrap'

/Users/bsipocz/.pyenv/versions/3.12.1/lib/python3.12/site-packages/docutils/nodes.py:596: KeyError
======================================================================= short test summary info =======================================================================
FAILED tests/test_execute.py::test_complex_outputs_unrun_cache - KeyError: 'no-wrap'
FAILED tests/test_execute.py::test_complex_outputs_unrun_auto - KeyError: 'no-wrap'
FAILED tests/test_glue.py::test_parser - KeyError: 'no-wrap'
FAILED tests/test_parser.py::test_complex_outputs - KeyError: 'no-wrap'
FAILED tests/test_parser.py::test_ipywidgets - KeyError: 'no-wrap'
FAILED tests/test_render_outputs.py::test_complex_outputs - KeyError: 'no-wrap'
==================================================================== 6 failed, 79 passed in 56.63s ====================================================================

I use the latest docutils version to trigger the issue, 0.21.2; and it all goes away by reverting the nowrap-->no-wrap change made in #13264 in mathjax.py

How to Reproduce

Run pytest for MyST-NB with development version of sphinx and latest release docutils

Environment Information

Please paste all output below into the bug report template



Platform:              darwin; (macOS-12.5.1-arm64-arm-64bit)
Python version:        3.12.1 (main, Dec 22 2023, 11:59:08) [Clang 14.0.0 (clang-1400.0.29.202)])
Python implementation: CPython
Sphinx version:        8.2.0
Docutils version:      0.21.2
Jinja2 version:        3.1.4
Pygments version:      2.18.0

Sphinx extensions

Additional context

No response

@AA-Turner
Copy link
Member

Run pytest for MyST-NB with development version of sphinx and latest release docutils

Do you have a more minimal reproducer?

A

@bsipocz
Copy link
Contributor Author

bsipocz commented Feb 7, 2025

I haven't got around figuring out one yet.

@AA-Turner AA-Turner added this to the 8.2.0 milestone Feb 7, 2025
@AA-Turner
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants