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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnboundLocalError in convert.py #487

Open
funkyfuture opened this issue Apr 6, 2023 · 1 comment
Open

UnboundLocalError in convert.py #487

funkyfuture opened this issue Apr 6, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@funkyfuture
Copy link

Describe the bug

context
I added myst-nb to an existing documentation that includes a .ipynb file and invoke make html.

expectation
A neat result.

bug
But instead 馃悰UnboundLocalError馃悰 happens
Here's an error message I ran into...

# Sphinx version: 5.3.0
# Python version: 3.11.2 (CPython)
# Docutils version: 0.19 
# Jinja2 version: 3.1.2
# Last messages:
#   updating environment:
#   [new config]
#   11 added, 0 changed, 0 removed
#   reading sources... [  9%] api
#   reading sources... [ 18%] api-note
#   reading sources... [ 27%] changes
#   reading sources... [ 36%] design
#   reading sources... [ 45%] extending
#   reading sources... [ 54%] genindex
#   reading sources... [ 63%] getting_started
# Loaded extensions:
#   sphinx.ext.mathjax (5.3.0) from /home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinx/ext/mathjax.py
#   sphinxcontrib.applehelp (1.0.4) from /home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinxcontrib/applehelp/__init__.py
#   sphinxcontrib.devhelp (1.0.2) from /home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinxcontrib/devhelp/__init__.py
#   sphinxcontrib.htmlhelp (2.0.1) from /home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinxcontrib/htmlhelp/__init__.py
#   sphinxcontrib.serializinghtml (1.1.5) from /home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinxcontrib/serializinghtml/__init__.py
#   sphinxcontrib.qthelp (1.0.3) from /home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinxcontrib/qthelp/__init__.py
#   alabaster (0.7.13) from /home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/alabaster/__init__.py
#   autoclasstoc (1.6.0) from /home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/autoclasstoc/__init__.py
#   myst_nb (0.17.1) from /home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/myst_nb/__init__.py
#   sphinx.ext.autodoc.preserve_defaults (5.3.0) from /home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinx/ext/autodoc/preserve_defaults.py
#   sphinx.ext.autodoc.type_comment (5.3.0) from /home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinx/ext/autodoc/type_comment.py
#   sphinx.ext.autodoc.typehints (5.3.0) from /home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinx/ext/autodoc/typehints.py
#   sphinx.ext.autodoc (5.3.0) from /home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinx/ext/autodoc/__init__.py
#   sphinx.ext.autosummary (5.3.0) from /home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinx/ext/autosummary/__init__.py
#   sphinx.ext.doctest (5.3.0) from /home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinx/ext/doctest.py
#   sphinx.ext.intersphinx (5.3.0) from /home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinx/ext/intersphinx.py
#   sphinx.ext.viewcode (5.3.0) from /home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinx/ext/viewcode.py
#   sphinxcontrib.fulltoc (unknown version) from /home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinxcontrib/fulltoc.py
Traceback (most recent call last):
  File "/home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinx/cmd/build.py", line 281, in build_main
    app.build(args.force_all, args.filenames)
  File "/home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinx/application.py", line 347, in build
    self.builder.build_update()
  File "/home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinx/builders/__init__.py", line 310, in build_update
    self.build(to_build,
  File "/home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinx/builders/__init__.py", line 326, in build
    updated_docnames = set(self.read())
                           ^^^^^^^^^^^
  File "/home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinx/builders/__init__.py", line 433, in read
    self._read_serial(docnames)
  File "/home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinx/builders/__init__.py", line 454, in _read_serial
    self.read_doc(docname)
  File "/home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinx/builders/__init__.py", line 510, in read_doc
    publisher.publish()
  File "/home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/docutils/core.py", line 224, in publish
    self.document = self.reader.read(self.source, self.parser,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/sphinx/io.py", line 104, in read
    self.parse()
  File "/home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/docutils/readers/__init__.py", line 76, in parse
    self.parser.parse(self.input, document)
  File "/home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/myst_nb/sphinx_.py", line 87, in parse
    notebook = nb_reader.read(inputstring)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/myst_nb/core/read.py", line 38, in standard_nb_read
    return nbf.reads(text, as_version=NOTEBOOK_VERSION)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/nbformat/__init__.py", line 91, in reads
    nb = convert(nb, as_version)
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/nbformat/converter.py", line 56, in convert
    converted = convert_function(nb)
                ^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/hatch/env/virtual/project/pFhfpXCQ/docs/lib/python3.11/site-packages/nbformat/v2/convert.py", line 47, in upgrade
    ws.cells.append(newcell)
                    ^^^^^^^
UnboundLocalError: cannot access local variable 'newcell' where it is not associated with a value

Reproduce the bug

see above.

List your environment

No response

@funkyfuture funkyfuture added the bug Something isn't working label Apr 6, 2023
@welcome
Copy link

welcome bot commented Apr 6, 2023

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 馃

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 馃帀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant