facebook / facebook/pyrefly

cached_property overriding unannotated class variable

Open
#3,062 2 comments 0 reactions 1 assignee Claimed by @asukaminato0721 View on GitHub
typechecking usability
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

Minmal repro:
```python
from functools import cached_property

class BaseDatabaseFeatures2:
can_introspect_fk = True
update_can_self_select = True

class MySQLFeatures(BaseDatabaseFeatures2):
@cached_property
def can_introspect_fk(self): # FP: property but BaseDatabaseFeatures2.can_introspect_fk is not
return self._check()

@cached_property
def update_can_self_select(self): # FP: property but parent is not
return True

def _check(self) -> bool:
return False
```
`cached_property` is defined to be settable on typeshed. No other type checker wants to error on this, at least by default.

### Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEYArugMYAuuuUcdENxuSmzotULABYxMAfWLViMIaQA66VSyio4PAEJaYAEVRtU2fQDEYxxpXgAmRKrrORGaRHRtqcBe2lgAazoAXjoAFUpGGCcXRmJMYxhpUXRpOBgoMDSMmHYQ8MjotWKNLR4AWVIAZQBFABlLa1s4AAo9dKMTM3TGtht7AEpHdBc6AAFRCSlZeUU2FRGXTBgwV1SPL1wfXLZ-AJb0zKHnAGI6cwAFRDo5XAUlOmxGYXbDY1MLKz7mu0IU9083l8u0CvB46FwbBio2ctm%2BI0OYEIyUkLH2A1U0PGk0kMlu93mWOWqziCTYSX%2BiOysHYBwyYGOdDOl2u%2BLmpEezxuqFsnjBdAhUMWMLocJsIwiUUxwroxLoKNy%2B0RAzoAFoAHyPThQYYi2EweHnVDcGAgAA0IGe0DgJHIiBAZwAqmxoBB5gxmOwILh0HBpXKwIIaMZpOhGDRsIoWvhrhsVRq6HAvLqXGLKCMwMoQAA5cORyjXYD4AC%2BWdU5pAZFsYCgpEIHBoUAoZwupGrtcTGBwBBEPsgAHMbMZvehCKozlUYDA6OI2GxiHBEAB6JdVla1wiCftLmDoJeYXAsOBLlh9iCDyjDn1LhiCOioABuqGgplgvfQA6HLp9dDu399Y7oGQbDiD6qoPoocAjvkWYAMyEAAjHYZboCAxYWmILoQeY0CmvaaBYHgRBkGhQA

### (Only applicable for extension issues) IDE Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.