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

autodata could not create document for instance variables with type annotation #8443

Closed
tk0miya opened this issue Nov 18, 2020 · 0 comments
Closed

Comments

@tk0miya
Copy link
Member

tk0miya commented Nov 18, 2020

Describe the bug
autodata could not create document for instance variables with type annotation.

To Reproduce

# example.py
var: int
# index.rst
.. autodata:: example.var

It causes AttributeError

WARNING: autodoc: failed to import data 'var' from module 'example'; the following exception was raised:
Traceback (most recent call last):
  File "/Users/tkomiya/work/sphinx/sphinx/util/inspect.py", line 343, in safe_getattr
    return getattr(obj, name, *defargs)
AttributeError: module 'example' has no attribute 'var'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/tkomiya/work/sphinx/sphinx/ext/autodoc/importer.py", line 106, in import_object
    obj = attrgetter(obj, mangled_name)
  File "/Users/tkomiya/work/sphinx/sphinx/ext/autodoc/__init__.py", line 316, in get_attr
    return autodoc_attrgetter(self.env.app, obj, name, *defargs)
  File "/Users/tkomiya/work/sphinx/sphinx/ext/autodoc/__init__.py", line 2269, in autodoc_attrgetter
    return safe_getattr(obj, name, *defargs)
  File "/Users/tkomiya/work/sphinx/sphinx/util/inspect.py", line 359, in safe_getattr
    raise AttributeError(name) from exc
AttributeError: var

Expected behavior
Document should be generated successfully like when I used automodule.

Your project
N/A

Screenshots
N/A

Environment info

  • OS: Mac
  • Python version: 3.9.0
  • Sphinx version: HEAD of 3.x
  • Sphinx extensions: sphinx.ext.autodoc
  • Extra tools: Nothing

Additional context
Nothing

@tk0miya tk0miya added this to the 3.4.0 milestone Nov 18, 2020
tk0miya added a commit that referenced this issue Nov 20, 2020
Fix #8443: autodata directive does not support PEP-526 ivars
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant