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

Patched PropertyDocumenter fails on properties created using @functools.cached_property #104

Closed
antonymayi opened this issue May 25, 2022 · 0 comments

Comments

@antonymayi
Copy link
Contributor

Sphinx analyses properties created with the @functools.cached_property as a normal property using the PropertyDocumenter which sphinx-immaterial patches with additional _get_property_return_type function. That assumes the property object has a .fget attribute/method which, however, is not the case for cached_property objects, hence failing with AttributeError:

  File "/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 1792, in document_members
    super().document_members(all_members)
  File "/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 857, in document_members
    documenter.generate(
  File "/lib/python3.9/site-packages/sphinx/ext/autodoc/__init__.py", line 910, in generate
    if not self.import_object():
  File "/lib/python3.9/site-packages/sphinx_immaterial/autodoc_property_type.py", line 41, in import_object
    self.retann = _get_property_return_type(self.object)
  File "/lib/python3.9/site-packages/sphinx_immaterial/autodoc_property_type.py", line 15, in _get_property_return_type
    if obj.fget is None:
AttributeError: 'cached_property' object has no attribute 'fget'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant