-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Instance attributes are incorrectly added to Parent class with Sphinx 3.4.0 #8567
Labels
Milestone
Comments
Note that |
tk0miya
added a commit
to tk0miya/sphinx
that referenced
this issue
Dec 21, 2020
…ed to Parent class The instance attributes on subclasses are shown on the document of parent class unexpectedly because of autodoc modifies `__annotations__` in place. This fix creates a copy of `__annotations__` attribute and attach it to the subclass.
Thank you for your good report. I posted a fix for this now. It will be released in this week (after other bugs will be also fixed). |
tk0miya
added a commit
to tk0miya/sphinx
that referenced
this issue
Dec 21, 2020
…ed to Parent class The instance attributes on subclasses are shown on the document of parent class unexpectedly because of autodoc modifies `__annotations__` in place. This fix creates a copy of `__annotations__` attribute and attach it to the subclass.
@tk0miya Thank you for the quick response :) |
tk0miya
added a commit
to tk0miya/sphinx
that referenced
this issue
Dec 21, 2020
…ed to Parent class The instance attributes on subclasses are shown on the document of parent class unexpectedly because of autodoc modifies `__annotations__` in place. This fix creates a copy of `__annotations__` attribute and attach it to the subclass.
tk0miya
added a commit
that referenced
this issue
Dec 22, 2020
Fix #8567: autodoc: Instance attributes are incorrectly added to Parent class
This was referenced Dec 27, 2020
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the bug
Trying to build the docs of QCoDeS microsoft/Qcodes#2549 with Sphinx 3.4.0 we are
seeing a failure where an instance attribute on a class cannot be resolved. This attribute is not defined on that class
but only on a different subclass. e.g.
visabackend
is defined onVisaInstrument
but not on the parent class ofVisaInstrument
calledInstrument
but Sphinx tries to get that attribute on a non related subclass of InstrumentATS
This happens because Sphinx modifies
__attributes__
in place. If a subclass does not define new class attributes it will reuse the__attributes__
dict of the super class as seen in the following simple example:And
AttributeDocumenter.update_annotations
modifies the annotation dictionary of the subclass in place causing the annotation dictionary of the super class to be modified with it.Replacing this with something that does
Seems to resolve the issue
To Reproduce
Expected behavior
Only the relevant attributes are attempted to be imported and the docs build correctly.
Your project
github.com/qcodes/qcodes
Screenshots
If applicable, add screenshots to help explain your problem.
Environment info
'sphinx.ext.napoleon', 'sphinx-jsonschema', 'sphinx.ext.doctest',
'sphinx.ext.intersphinx', 'sphinx.ext.todo',
'sphinx.ext.coverage', 'sphinx.ext.mathjax',
'sphinx.ext.viewcode', 'sphinx.ext.githubpages',
'sphinx.ext.todo']
The text was updated successfully, but these errors were encountered: