Autosummary issue with aliased names
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- documentation
Research direction
Reproduce the issue with the example_bug/init.py, example_bug/_impl.py, source/index.rst, and source/conf.py files using the shown sphinx-build command. Start with the autosummary extension's handling of the aliased Foo class and its uninitialized bar attribute. Done means the build no longer warns about Foo.bar and both attributes are documented.
Written by the indexing model from the issue text.
Description
Describe the bug
Sphinx fails to resolve class attributes when they do not have a default, and when the class that they belong to have been aliased (e.g. by changing the class' __module__ attribute). It correctly resolves the attribute when it has a value.
How to Reproduce
Minimal method:
$ tree .
.
├── example_bug
│ ├── _impl.py
│ └── __init__.py
└── source
├── conf.py
└── index.rst
index.rst:
Test
====
.. autosummary::
:toctree: api
example_bug.Foo
conf.py:
project = 'autosummary-bug'
extensions = ['sphinx.ext.autosummary']
The code to document:
example_bug/__init__.py:
from ._impl import Foo
Foo.__module__ =__name__
example_bug/_impl.py:
class Foo:
bar: int
foo: float = 3.14
The problem:
PYTHONPATH=$(pwd) sphinx-build source/ build/html/ -W --keep-going
Running Sphinx v6.0.0b3+/d8977d3e5
making output directory... done
[autosummary] generating autosummary for: index.rst
[autosummary] generating autosummary for: source/api/example_bug.Foo.rst
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: [new config] 2 added, 0 changed, 0 removed
reading sources... [100%] index
source/api/example_bug.Foo.rst:24: WARNING: autosummary: failed to import Foo.bar.
Possible hints:
* KeyError: 'Foo'
* ImportError:
* AttributeError: type object 'Foo' has no attribute 'Foo'
* AttributeError: type object 'Foo' has no attribute 'bar'
* ModuleNotFoundError: No module named 'example_bug.Foo'
* ModuleNotFoundError: No module named 'Foo'
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
generating indices... genindex done
writing additional pages... search done
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build finished with problems, 1 warning.
Notice that Foo.bar is not documented, but Foo.foo is.
Environment Information
Platform: linux; (Linux-5.4.0-135-generic-x86_64-with-glibc2.31)
Python version: 3.9.7 (default, Sep 16 2021, 13:09:58)
[GCC 7.5.0])
Python implementation: CPython
Sphinx version: 6.0.0b3+/d8977d3e5
Docutils version: 0.19
Jinja2 version: 3.1.2
Sphinx extensions
autosummary
Additional context
No response
- Dominant language
- Python
- Stars
- 8k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sphinx-doc/sphinx
-
type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
sphinx-doc/sphinx#14699 ·
-
type:bug type:tests
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sphinx-doc/sphinx#14678 ·
-
type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
sphinx-doc/sphinx#14659 ·
-
autodoc: IndexError formatting signature for callable data object with annotated class variable Openextensions:autodoc type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
sphinx-doc/sphinx#14576 · 2 comments ·
-
extensions:autodoc extensions:autosummary type:bug type:docs
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
sphinx-doc/sphinx#14555 · 2 comments ·
All issues in sphinx-doc/sphinx
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100