Skip to content

autodoc tries to import classes as modules #98

Closed
@amueller

Description

@amueller

From sphinx-doc/sphinx#3768 as I suspect it might be a numpydoc issue after all.

After updating sphinx and numpydoc, I get

WARNING: /home/andy/checkout/scikit-learn/doc/modules/generated/sklearn.preprocessing.RobustScaler.rst:92: (WARNING/2) autodoc: failed to import method 'RobustScaler.__init__' from module 'sklearn.preprocessing.data.RobustScaler'; the following exception was raised:
Traceback (most recent call last):
  File "/home/andy/anaconda3/lib/python3.5/site-packages/sphinx/ext/autodoc.py", line 658, in import_object
    __import__(self.modname)
ImportError: No module named 'sklearn.preprocessing.data.RobustScaler'; 'sklearn.preprocessing.data' is not a package

for every class in the package.

It looks like the modname is wrong as it is the class and not the module. I'm not sure what should be imported at this point, though. The class? Importing a method doesn't seem to make a lot of sense...

Repo to reproduce:
https://github.com/amueller/sphinx-debug

WARNING: /home/andy/checkout/sphinx-debug/doc/modules/generated/blablub.BaseEstimator.rst:28: (WARNING/2) autodoc: failed to import method 'BaseEstimator.__init__' from module 'blablub.BaseEstimator'; the following exception was raised:
Traceback (most recent call last):
  File "/home/andy/checkout/sphinx/sphinx/ext/autodoc.py", line 657, in import_object
    __import__(self.modname)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions