facebook / facebook/pyrefly

Inconsistency between checkers when overriding property w/ regular attribute

Open
#2,771 1 comment 0 reactions 0 assignees View on GitHub
needs-discussion typechecking
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

```python
from abc import ABC, abstractmethod
from functools import cached_property

class A(ABC):
@property
@abstractmethod
def x(self) -> int:
pass

class B1(A):
def __init__(self):
self.x = 1 # mypy: ✅, pyright: ❌, pyrefly: ❌, runtime: error

class B2(A):
x = 1 # mypy: ✅, pyright: ❌, pyrefly: ✅

class C:
@cached_property
def x(self) -> int:
return 0

class D1(C):
def __init__(self):
self.x = 1 # mypy: ✅, pyright: ✅, pyrefly: ✅

class D2(C):
x = 1 # mypy: ✅, pyright: ❌, pyrefly: ✅

class E:
x = cached_property(lambda _: 1)

class F1(E):
def __init__(self):
self.x = 1 # mypy: ✅, pyright: ✅, pyrefly: ✅

class F2(E):
x = 1 # mypy: ✅, pyright: ✅, pyrefly: ❌

```

We are correct to error on B1. I don't understand why D2 and F2 have different results, or why Pyright does the opposite

### Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEq2AxnRDcbpQC50CCAQgGEANA2xwulVEy40YXABa5MAHXRhq9MAFd0M3LihxW7TjybSFMTAH1i1YjG6k1aplFRxjvABQDBAJSIanShdAAC9riOziFh4YwSUjJyispxoZgwYHT4PnAwUGABdAC0AHys6FzB6GH1dMSecK56Hl50-ACMfkEZdFk5NjYQ6BBcw-mFxbUNYQVFhPh0ALx0XXQAxHQ0pGSIdICg5KJklBAA5go1dIAy5CeklNlQpAd3dJS6XGwwB07UlK13M1OgAmXqzMLLNYbba7fZHe5nS7XN6nJ4vI79NztYyCCGhcIWJhWWxRGJcFx1MKDXJTIolCpVGr9eqPLjaSh1AAMLLC2OBABEeoF8QNsnRhqNxpMFjNeaFZUtVustjs9hjjo0HhcrgdNWiwM89fK6PyOgKwSL%2BlCVbD1XrETqUYj0cb0GbjABRUU2okkuwOJwUnweGjYTCoCUHLoBQE4ugAMR6nr6VMy4slYwmNjpcrTDUVNphavh%2Bu1yIdWseho1Jo9ibBKZ9yuLcI1jorCKrrtuahAwhABuehC4tCgFG2AAUHui6GgsHhlkxcOoLhzUF8V4Q1NsAMowGB0K5cYhwRAAenPQ9IhE453PMHQ58wuCYcHPy9X53Xm6fdDAnAMAAbqg0CMLAdCfpA35SL%2BdDRL%2BcDbugZBpOgpRAU4cAQCuyoqCAADMhBdCC%2BF9gAvgO0hfJhCbQDAFDzjgBAkOQ5FAA

### (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.