readthedocs / sphinx-autoapi

A new approach to API documentation in Sphinx.
https://sphinx-autoapi.readthedocs.io/
MIT License
415 stars 126 forks source link

sphinx-autoapi fails with astroid 3.0.0 #407

Closed zaneselvans closed 9 months ago

zaneselvans commented 9 months ago

astroid released v3.0.0 this morning, and it appears to break sphinx-autoapi, resulting (on our builds) in:

Extension error (autoapi.extension):
Handler <function run_autoapi at 0x7fdba2af9c60> for event 'builder-inited' threw an exception (exception: 'Module' object has no attribute 'doc')

See e.g. this docs build on RTD

Adding a dependency to our pyproject.toml which requires astroid<3 results in the documentation build succeeding.

Stack trace from the above RTD build:

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/catalystcoop-pudl/conda/2893/lib/python3.11/site-packages/sphinx/events.py", line 97, in emit
    results.append(listener.handler(self.app, *args))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/catalystcoop-pudl/conda/2893/lib/python3.11/site-packages/autoapi/extension.py", line 153, in run_autoapi
    if sphinx_mapper_obj.load(
       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/catalystcoop-pudl/conda/2893/lib/python3.11/site-packages/autoapi/mappers/python/mapper.py", line 300, in load
    data = self.read_file(path=path, dir_root=dir_root)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/catalystcoop-pudl/conda/2893/lib/python3.11/site-packages/autoapi/mappers/python/mapper.py", line 318, in read_file
    parsed_data = Parser().parse_file(path)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/catalystcoop-pudl/conda/2893/lib/python3.11/site-packages/autoapi/mappers/python/parser.py", line 41, in parse_file
    return self._parse_file(
           ^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/catalystcoop-pudl/conda/2893/lib/python3.11/site-packages/autoapi/mappers/python/parser.py", line 38, in _parse_file
    return self.parse(node)
           ^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/catalystcoop-pudl/conda/2893/lib/python3.11/site-packages/autoapi/mappers/python/parser.py", line 265, in parse
    data = parse_func(node)
           ^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/catalystcoop-pudl/conda/2893/lib/python3.11/site-packages/autoapi/mappers/python/parser.py", line 240, in parse_module
    "doc": _prepare_docstring(node.doc or ""),
                              ^^^^^^^^
AttributeError: 'Module' object has no attribute 'doc'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/catalystcoop-pudl/conda/2893/lib/python3.11/site-packages/sphinx/cmd/build.py", line 293, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/docs/checkouts/readthedocs.org/user_builds/catalystcoop-pudl/conda/2893/lib/python3.11/site-packages/sphinx/application.py", line 272, in __init__
    self._init_builder()
  File "/home/docs/checkouts/readthedocs.org/user_builds/catalystcoop-pudl/conda/2893/lib/python3.11/site-packages/sphinx/application.py", line 343, in _init_builder
    self.events.emit('builder-inited')
  File "/home/docs/checkouts/readthedocs.org/user_builds/catalystcoop-pudl/conda/2893/lib/python3.11/site-packages/sphinx/events.py", line 108, in emit
    raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function run_autoapi at 0x7fbb366d1b20> for event 'builder-inited' threw an exception (exception: 'Module' object has no attribute 'doc')

Extension error (autoapi.extension):
Handler <function run_autoapi at 0x7fbb366d1b20> for event 'builder-inited' threw an exception (exception: 'Module' object has no attribute 'doc')
AWhetter commented 9 months ago

I won't be able to look at this for another 4 hours or so. It looks like most of this was fixed already (https://github.com/readthedocs/sphinx-autoapi/commit/0ba883ab891b18aca00d7931a91ecf3aafb2439c), but there's a reference to the old attribute in the inheritance_diagram.py that's causing tox -e docs to fail as well.

ProkhorZakharov commented 9 months ago

Downgrading to astroid==2.15.8 works for now!