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

Commit d16d9a6 is a breaking change #9832

Closed
Yoshanuikabundi opened this issue Nov 9, 2021 · 2 comments · Fixed by #9833
Closed

Commit d16d9a6 is a breaking change #9832

Yoshanuikabundi opened this issue Nov 9, 2021 · 2 comments · Fixed by #9833
Labels

Comments

@Yoshanuikabundi
Copy link
Contributor

Describe the bug

When testing #9831 on a work project, I found that it could not build on the current state of the 4.x branch. I've bisected it down to commit d16d9a6 and confirmed that reverting this commit fixes the error. I haven't dug any further than that.

Traceback/log
# Sphinx version: 4.3.0+/d16d9a666
# Python version: 3.9.7 (CPython)
# Docutils version: 0.17.1 release
# Jinja2 version: 3.0.2
# Last messages:
#   reading sources... [  7%] _autosummary/openff.bespokefit.executor.services.coordinator
#   reading sources... [  7%] _autosummary/openff.bespokefit.executor.services.coordinator.app
#   reading sources... [  7%] _autosummary/openff.bespokefit.executor.services.coordinator.app.get_molecule_image
#   reading sources... [  8%] _autosummary/openff.bespokefit.executor.services.coordinator.app.get_optimization
#   reading sources... [  8%] _autosummary/openff.bespokefit.executor.services.coordinator.app.get_optimizations
#   reading sources... [  8%] _autosummary/openff.bespokefit.executor.services.coordinator.app.post_optimization
#   reading sources... [  8%] _autosummary/openff.bespokefit.executor.services.coordinator.app.shutdown
#   reading sources... [  8%] _autosummary/openff.bespokefit.executor.services.coordinator.app.startup
#   reading sources... [  9%] _autosummary/openff.bespokefit.executor.services.coordinator.models
#   reading sources... [  9%] _autosummary/openff.bespokefit.executor.services.coordinator.models.CoordinatorGETPageResponse
# Loaded extensions:
#   sphinx.ext.mathjax (4.3.0+/d16d9a666) from /home/joshmitchell/Documents/sphinx/sphinx/ext/mathjax.py
#   sphinxcontrib.applehelp (1.0.2) from /home/joshmitchell/.local/lib/python3.9/site-packages/sphinxcontrib/applehelp/__init__.py
#   sphinxcontrib.devhelp (1.0.2) from /home/joshmitchell/.local/lib/python3.9/site-packages/sphinxcontrib/devhelp/__init__.py
#   sphinxcontrib.htmlhelp (2.0.0) from /home/joshmitchell/.local/lib/python3.9/site-packages/sphinxcontrib/htmlhelp/__init__.py
#   sphinxcontrib.serializinghtml (1.1.5) from /home/joshmitchell/.local/lib/python3.9/site-packages/sphinxcontrib/serializinghtml/__init__.py
#   sphinxcontrib.qthelp (1.0.3) from /home/joshmitchell/.local/lib/python3.9/site-packages/sphinxcontrib/qthelp/__init__.py
#   alabaster (0.7.12) from /home/joshmitchell/.local/lib/python3.9/site-packages/alabaster/__init__.py
#   sphinx.ext.autodoc.preserve_defaults (1.0) from /home/joshmitchell/Documents/sphinx/sphinx/ext/autodoc/preserve_defaults.py
#   sphinx.ext.autodoc.type_comment (4.3.0+/d16d9a666) from /home/joshmitchell/Documents/sphinx/sphinx/ext/autodoc/type_comment.py
#   sphinx.ext.autodoc (4.3.0+/d16d9a666) from /home/joshmitchell/Documents/sphinx/sphinx/ext/autodoc/__init__.py
#   sphinx.ext.autosummary (4.3.0+/d16d9a666) from /home/joshmitchell/Documents/sphinx/sphinx/ext/autosummary/__init__.py
#   sphinx.ext.viewcode (4.3.0+/d16d9a666) from /home/joshmitchell/Documents/sphinx/sphinx/ext/viewcode.py
#   sphinx.ext.napoleon (4.3.0+/d16d9a666) from /home/joshmitchell/Documents/sphinx/sphinx/ext/napoleon/__init__.py
#   sphinx.ext.intersphinx (4.3.0+/d16d9a666) from /home/joshmitchell/Documents/sphinx/sphinx/ext/intersphinx.py
#   sphinx.ext.extlinks (4.3.0+/d16d9a666) from /home/joshmitchell/Documents/sphinx/sphinx/ext/extlinks.py
#   myst_parser (0.15.2) from /home/joshmitchell/conda/envs/bespokefitdev/lib/python3.9/site-packages/myst_parser/__init__.py
#   sphinxcontrib.autodoc_pydantic (1.5.0) from /home/joshmitchell/conda/envs/bespokefitdev/lib/python3.9/site-packages/sphinxcontrib/autodoc_pydantic/__init__.py
#   openff_sphinx_theme (0.0.32+104.g47ffca4) from /home/joshmitchell/Documents/openff/openff-sphinx-theme/openff_sphinx_theme/__init__.py
Traceback (most recent call last):
  File "/home/joshmitchell/Documents/sphinx/sphinx/cmd/build.py", line 280, in build_main
    app.build(args.force_all, filenames)
  File "/home/joshmitchell/Documents/sphinx/sphinx/application.py", line 343, in build
    self.builder.build_update()
  File "/home/joshmitchell/Documents/sphinx/sphinx/builders/__init__.py", line 293, in build_update
    self.build(to_build,
  File "/home/joshmitchell/Documents/sphinx/sphinx/builders/__init__.py", line 307, in build
    updated_docnames = set(self.read())
  File "/home/joshmitchell/Documents/sphinx/sphinx/builders/__init__.py", line 414, in read
    self._read_serial(docnames)
  File "/home/joshmitchell/Documents/sphinx/sphinx/builders/__init__.py", line 435, in _read_serial
    self.read_doc(docname)
  File "/home/joshmitchell/Documents/sphinx/sphinx/builders/__init__.py", line 475, in read_doc
    doctree = read_doc(self.app, self.env, self.env.doc2path(docname))
  File "/home/joshmitchell/Documents/sphinx/sphinx/io.py", line 189, in read_doc
    pub.publish()
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/core.py", line 217, in publish
    self.document = self.reader.read(self.source, self.parser,
  File "/home/joshmitchell/Documents/sphinx/sphinx/io.py", line 109, in read
    self.parse()
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/readers/__init__.py", line 78, in parse
    self.parser.parse(self.input, document)
  File "/home/joshmitchell/Documents/sphinx/sphinx/parsers.py", line 101, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 170, in run
    results = StateMachineWS.run(self, input_lines, input_offset,
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/statemachine.py", line 239, in run
    context, next_state, result = self.check_line(
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/statemachine.py", line 451, in check_line
    return method(match, context, next_state)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2769, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 393, in new_subsection
    newabsoffset = self.nested_parse(
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/statemachine.py", line 239, in run
    context, next_state, result = self.check_line(
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/statemachine.py", line 451, in check_line
    return method(match, context, next_state)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2344, in explicit_markup
    self.explicit_list(blank_finish)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2369, in explicit_list
    newline_offset, blank_finish = self.nested_list_parse(
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 318, in nested_list_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/statemachine.py", line 239, in run
    context, next_state, result = self.check_line(
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/statemachine.py", line 451, in check_line
    return method(match, context, next_state)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2647, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2354, in explicit_construct
    return method(self, expmatch)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2096, in directive
    return self.run_directive(
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2146, in run_directive
    result = directive_instance.run()
  File "/home/joshmitchell/Documents/sphinx/sphinx/ext/autodoc/directive.py", line 173, in run
    result = parse_generated_content(self.state, params.result, documenter)
  File "/home/joshmitchell/Documents/sphinx/sphinx/ext/autodoc/directive.py", line 120, in parse_generated_content
    state.nested_parse(content, 0, node)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 281, in nested_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/statemachine.py", line 239, in run
    context, next_state, result = self.check_line(
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/statemachine.py", line 451, in check_line
    return method(match, context, next_state)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2342, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2354, in explicit_construct
    return method(self, expmatch)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2096, in directive
    return self.run_directive(
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/parsers/rst/states.py", line 2146, in run_directive
    result = directive_instance.run()
  File "/home/joshmitchell/Documents/sphinx/sphinx/domains/__init__.py", line 286, in run
    return super().run()
  File "/home/joshmitchell/Documents/sphinx/sphinx/directives/__init__.py", line 189, in run
    name = self.handle_signature(sig, signode)
  File "/home/joshmitchell/Documents/sphinx/sphinx/domains/python.py", line 485, in handle_signature
    signode += addnodes.desc_annotation(str(sig_prefix), '', *sig_prefix)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/nodes.py", line 1170, in __init__
    TextElement.__init__(self, rawsource, text, *children, **attributes)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/nodes.py", line 1162, in __init__
    Element.__init__(self, rawsource, *children, **attributes)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/nodes.py", line 554, in __init__
    self.extend(children)           # maintain parent info
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/nodes.py", line 754, in extend
    self.append(node)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/nodes.py", line 749, in append
    self.setup_child(item)
  File "/home/joshmitchell/.local/lib/python3.9/site-packages/docutils/nodes.py", line 146, in setup_child
    child.parent = self
AttributeError: 'str' object has no attribute 'parent'

How to Reproduce

$ git clone https://github.com/openforcefield/bespoke-fit.git
$ cd bespoke-fit
$ git checkout docs-update
$ mamba env create --file devtools/conda-envs/test-env.yaml --name bespokefit
$ mamba activate bespokefit
$ cd docs
$ make html

Expected behavior

The docs build successfully.

Your project

https://github.com/openforcefield/bespoke-fit

Screenshots

No response

OS

Linux Arch

Python version

3.10

Sphinx version

Commits on 4.x after d16d9a6

Sphinx extensions

"sphinx.ext.autosummary",     "sphinx.ext.autodoc",     "sphinx.ext.mathjax",     "sphinx.ext.viewcode",     "sphinx.ext.napoleon",     "sphinx.ext.intersphinx",     "sphinx.ext.extlinks",     "myst_parser",     "sphinxcontrib.autodoc_pydantic",

Extra tools

No response

Additional context

No response

@jakobandersen
Copy link
Contributor

I think the triggering rst line is .. autopydantic_model:: BaseOptimizerSchema in _autosummary/openff.bespokefit.schema.optimizers.BaseOptimizerSchema.rst. This directive seems to be implemented in sphinxcontrib.autodoc_pydantic.
It overwrites get_signature_prefix which has its signature changed for 4.3 to allow better styling of declarations (https://www.sphinx-doc.org/en/master/changes.html#id2).
I have made #9833 to mitigate this, and your project should compile, but warn and render the pydantic model as plain text.

@Yoshanuikabundi
Copy link
Contributor Author

@jakobandersen Wow thanks! I'll report this to autodoc_pydantic too.

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

Successfully merging a pull request may close this issue.

2 participants