Skip to content

[stubgen] functools.cached_property is not supported #14980

@sobolevn

Description

@sobolevn

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 :)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions