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

parameters.py Absolute Imports break Sphinx Build #186

Closed
michaelweinold opened this issue Sep 8, 2024 · 4 comments
Closed

parameters.py Absolute Imports break Sphinx Build #186

michaelweinold opened this issue Sep 8, 2024 · 4 comments
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@michaelweinold
Copy link
Contributor

The recent move to absolute imports:

broke the inheritance-diagram functionality of the autoapi Sphinx extension:

A quick workaround would be to simply disable the generation of inheritance diagrams in conf.py like so:

autoapi_options = [
    'members',
    'undoc-members',
    'private-members',
    'show-inheritance',
    'show-module-summary',
    # 'show-inheritance-diagram' # commented out for debugging
]

Passing -v -v -v to the sphinx-build command, as documented allowed me to narrow the issue down the bw2data/parameters.py file:

(...)
[app] emitting event: 'source-read'('api/bw2data/parameters/index', ['bw2data.parameters\n==================\n\n.. py:module:: bw2data.
[app] emitting event: 'build-finished'(SphinxParallelError("AttributeError: 'AssignName' object has no attribute 'getattr'", 'Traceback (m
[AutoAPI] Cleaning generated .rst files

(Error in parallel process)
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniconda/base/envs/sphinx_documentation/lib/python3.12/site-packages/sphinx/util/parallel.py", line 76, in _process
    ret = func(arg)
(...)

Manually removing this file will result in a successful Sphinx build.

I will need to leave the remainder of this investigation to the gentlemen who broke the build in the first place (@cmutel et al.) 😬

I created a debugging repository that should make this fairly easy: https://github.com/michaelweinold/sphinx-autoapi-debugging

@michaelweinold michaelweinold added bug Something isn't working documentation Improvements or additions to documentation labels Sep 8, 2024
@michaelweinold
Copy link
Contributor Author

@cmutel, I painstakingly narrowed the issue down to the file/class structure now replicated here:

__init__.py:

from test_library.test_module import banana

test_module.py:

class highest:
    def __init__(self):
        self.a = 'a'

class middle(highest):
    def __init__(self):
        self.a = 'a'

class lowest:
    def __init__(self):
        self.db = "middle"

test_module = lowest()

It is all a little peculiar. If the instance of the lowest() class is named something other than the name of the module, such as banana = lowest(), no error is thrown. But even if the instance of the lowest() class is named test_module, the error can be avoided by not making the class middle() inherit from another class.

Maybe you can pick this up...

@cmutel
Copy link
Member

cmutel commented Sep 10, 2024

No idea how you even thought to debug in that direction... what about just moving parameters = ParameterManager() to __init__.py? This shouldn't break too much... the other option would be to change the filename parameters.py.

@michaelweinold
Copy link
Contributor Author

No idea how you even thought to debug in that direction...

images

what about just moving parameters = ParameterManager() to __init__.py? This shouldn't break too much...

It still does - sorry. You can quickly check my debugging repo: https://github.com/michaelweinold/sphinx-autoapi-debugging

the other option would be to change the filename parameters.py

From what I can see, this should work.

@michaelweinold
Copy link
Contributor Author

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

No branches or pull requests

2 participants