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

cached_property does not show typehint #9487

Closed
SwampFalc opened this issue Jul 22, 2021 · 3 comments
Closed

cached_property does not show typehint #9487

SwampFalc opened this issue Jul 22, 2021 · 3 comments

Comments

@SwampFalc
Copy link

Describe the bug

When documenting a functools.cache_property, the type hint is not shown.

How to Reproduce

I have a class that has a number of functools.cached_property methods.

Both through :members: as well as through autoproperty, I am unable to have them show their type hint.

To doublecheck, I turned some of them into regular property methods, and their type hint does get shown.

Expected behavior

functools.cached_property methods should show their typehint.

Your project

x-special/nautilus-clipboard copy file:///home/ldt/Projects/mde3/exportit/sphinx.zip

Screenshots

image

At the top, I changed it to a regular property, at the bottom I left it as a functools.cached_property.

OS

Linux Ubuntu 20.0.4

Python version

3.9.6

Sphinx version

4.1.1

Sphinx extensions

autodoc

Extra tools

No response

Additional context

No response

@SwampFalc
Copy link
Author

Oops, that upload failed...

sphinx.zip

@tk0miya
Copy link
Member

tk0miya commented Jul 22, 2021

Could you let me know the way to build this example? It seems some additional libraries are needed.

@tk0miya
Copy link
Member

tk0miya commented Jul 22, 2021

I reproduced the error with following code:

from functools import cached_property


class Foo:
    @property
    def prop1(self) -> int:
        """docstring"""
        return 0

    @cached_property
    def prop2(self) -> int:
        "docstring"

@tk0miya tk0miya added this to the 4.2.0 milestone Jul 22, 2021
tk0miya added a commit that referenced this issue Jul 24, 2021
Fix #9487: autodoc: typehint for cached_property is not shown
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 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

2 participants