facebook / facebook/pyrefly

Inconsistent error: Class member `Derived.method1` overrides parent class `Base` in an inconsistent manner [[bad-override]

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

Description

### Describe the Bug

```python
import abc

class Base(abc.ABC):
@classmethod
@abc.abstractmethod
def method1(cls) -> int:
return 1

@classmethod
@abc.abstractmethod
def method2(cls) -> int:
return 1

def a_method(cls) -> int:
return 1

class Derived(Base):
method2 = classmethod(a_method)
method1 = classmethod(lambda cls: 1)

```

pyrefly works with a declared method and fails for lambda function with error message:
```
ERROR sandbox.py:20:5-12: Class member `Derived.method1` overrides parent class `Base` in an inconsistent manner [[bad-override](https://pyrefly.org/en/docs/error-kinds/#bad-override)]
`Derived.method1` and `Base.method1` must both be descriptors
```

### Sandbox Link

https://pyrefly.org/sandbox/?code=MYGwhgzhAEBCkFMBcAoa7oAEIBcw4EtgBbBHACwHsATNDahAM2lIpoAoBKaAWgD5oBAHY5UGcdABOZAK6Sh0AIwoUDZmAD6rKtS68Bw0XXTScchcpShIMACIJJBAG4Jd8CAk5iM2mtAC80Lj4RL66mmGcQA&version=3.12

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