facebook / facebook/pyrefly

Avoid hard-error on naming-only inconsistent override

Open
#2,746 2 comments 0 reactions 0 assignees View on GitHub
typechecking usability
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

Minimal repro:
```python
class ConditionBase:
def __and__(self, other: object) -> "And":
return And()

def __or__(self, other: object) -> "Or":
return Or()

class AttributeBase:
def __and__(self, value: object) -> "And":
return And()

def __or__(self, value: object) -> "Or":
return Or()

class And:
pass

class Or:
pass

class ConditionAttributeBase( # FP: inconsistent-inheritance (__and__ and __or__)
ConditionBase,
AttributeBase,
):
pass
```
This is actually a name-only mismatch. For bad-override, we have a different error code for naming-only issues (which gets suppressed by default). We might want to do the same here as well given that no other type checker choose to flag this code.

### Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIAxlKnHAAQDCuWEALhCwEK0yIA66esPqYYYegH1JGTNIAUcGFDAAaerjYALGACdEG7ACsYlNgEp6AWgB89fiACCWBwKEiPumGwCuuoc6Y8uaCgh5iEtK4ugpKKuqaOvqGJmaWtvYgAPK6rmEeIl6%2B-vQ5waHo1LQMjmxsuhDYPmwwPEpu4eJSMlixymr0AG6oUD58KaYW1nYOgXnuBfRFfgFY5ej5whHd0X3xQyNjBrjGk%2Bkz2blImwXLJWUhG5U0dPSBHSLE1RVVrzkfwi%2BdB%2BLwYzFYHBYtXqjWarV48mEAGJ6AAxAAKBgglRYcAgcBa6DYVmxSXYGEoMHo8mksmk9FkOxikkeHnBmHYnHQbRgqhu0IaTRaPL56HMAPoQIQqhAzWgcBI5EQIBRAFUOFB2KR6GAfJVIeg4BVtmBogBbVBsSToHxm7B6eT4LFE870An6G53IRgBwAOVt9uSwHwAF8HIIQDKyF4wFBSIQ2LgzVAKCj0aQY3G3bI8Ph6JQWJAAOZ%2BS1cwiCFEAZRgVK0dWIcEQAHpm9HxHHCNEi82YOhm5hcJQ4M2C%2Bhi6WDc2ddEGcNoKhsLB84WICXdGWWBpiAaFYIyNoWFZBno8VuALyZADMhAAjAAmcPoEAhmWoMwQE%2Bo6AwChoLC5oqL5AA

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