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

[stubgen] functools.cached_property is not supported #14980

Closed
sobolevn opened this issue Mar 30, 2023 · 0 comments · Fixed by #14981
Closed

[stubgen] functools.cached_property is not supported #14980

sobolevn opened this issue Mar 30, 2023 · 0 comments · Fixed by #14981
Assignees
Labels
bug mypy got something wrong topic-descriptors Properties, class vs. instance attributes topic-stubgen

Comments

@sobolevn
Copy link
Member

After #8913 mypy can understand that @cached_property is a property.

So, I think that stubgen must reflect that. Right now if you run stubgen on this code:

from functools import cached_property

class A:
    @cached_property
    def x(self):
        return 'x'

You will get:

class A:
    def x(self): ...

This is incorrect, because it turns a property into a method.

But, ideally you should get:

from functools import cached_property

class A:
    @cached_property
    def x(self): ...

I already have a working prototype of the solution. Please, feel free to comment on the PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-descriptors Properties, class vs. instance attributes topic-stubgen
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant