Skip to content

Avoid hard-error on naming-only inconsistent override #2746

@grievejia

Description

@grievejia

Describe the Bug

Minimal repro:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    typecheckingusabilityUsability & readiness issues identified with running Pyrefly on top OSS projects

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions