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
Sphinx 3.1.1 name clash prevents autodoc importing. #7841
Comments
Hmm... this was introduced by #7815 for the fix of #7812. It's difficult to resolve both to me. It's terrible there are two components on the same python name. Ideally, Could you add a separator between the module name and object name like |
Thanks @tk0miya. That seems to have fixed it. I thought that there should be some way to disambiguate the module from the object but I couldn't find anything in the docs: |
Shouldn't the use of |
Indeed. How about
Sphinx also describes methods, attributes and so on. To do that, we need to split a module name and an object name from the given string. And now it tries to check the attribute exists on the shallower module. Please let me know if you have better idea. |
Thanks, I did not notice that. I'll work it later. |
Yes, @oscarbenjamin explained it well in sympy/sympy#19568 (comment). The problem is that there can be a difference between a dotted name as an attribute lookup and a dotted name as an import, and when there are objects with the same names as modules, there's no obvious way for Sphinx to disambiguate. Sphinx could maybe try to be smart and try the different ways of viewing a dotted expression and if there is exactly one match, chose that without any errors. I don't know if that is something that would be considered too magic or not. The colon notation seems like it should be sufficient to disambiguate when it is required. |
doc: Add modname separator tip for autodoc (refs: #7841)
I added documentation for |
Sphinx 3.1.1 seems to have changed the way that autodoc finds python imports which leads to two kinds of failure in building the sympy docs. Effectively the change is the difference between
compared to this
These are not equivalent and there are many cases in sympy where only the former works so autodoc fails to find many objects in sympy now.
This is a simple view of the relevant module structure in sympy:
In order.py there is a class called
Order
and in series.py there is a function calledseries
. The main sympy/init.py effectively doesIn this setup the Order class can be imported as
However it cannot be accessed through attributes from
sympy
e.g.:This is the same error as seen when building the sphinx docs:
This is because
getattr
is being used rather thanimportlib
to locate the import. These are not generally equivalent and it seems that sphinx 3.1.1 has switched from using one to use the other.There is another issue when attempting to reproduce this which is that there are many deprecated import objects in
sympy/__init__.py
and callinggetattr
on them triggers a deprecation warning:sympy/sympy#19554
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The docs would build successfully without warning like they do in 3.1.0
Your project
This was already mentioned on the sphinx mailing list:
https://groups.google.com/forum/#!msg/sphinx-users/mx83xLsDjBs/Qc3jW-z7AQAJ
Corresponding sympy issue:
sympy/sympy#19551
The text was updated successfully, but these errors were encountered: