Skip to content

false positive missing-override-decorator when overriding protocols #3987

Description

@thomasbaekkegaard

Describe the Bug

When type-checking the following, Pyrefly gives an error:

"Class member ConcreteImplementation.my_method overrides a member in a parent class but is missing an @override decorator Pyrefly[missing-override-decorator]"

class MyInterface(Protocol):

    def my_method(self, x: int) -> int:
        ...

class ConcreteImplementation(MyInterface):

    def my_method(self, x: int) -> int:  # 
        return x * 2

I believe this should be allowed on protocol classes (probably ABC's as well?).
Yes, I could just not inherit from the Protocol class, but I want to guard against not implementing all methods in a complex interface.

Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEALqcROgOZ0Q3G6UN0AFag1wBjXFAA66aaKio4cOgFlSASXQMYlMKlEwAFENwjxUAJSJpdG3UwwwdGqQD6NGAwAWuTAbgwoMAAaOnxETk1zOgBaAD4IhnDCZOlrW3tHf3EsNw9vX39AkNJwuAZKKLi6MsoklJkGuQUlAGFcdFFKDxg1blh3TVQGCHaDVQ0tHT0YSzSbDKdXdy8fPwDg0PDWBkr47at0WyO6LoYAV0pD-DoAKjoAJmkQIJAyLrAoUkIRGigKAGJBKR3p9qhgcAQ6NlIGwLkMRuhCNJAQBlGAwOieBgMYhwRAAenxbwcn0IvDY%2BJg6HxmDEcHx0IgsMo8Pa%2BLoYF4dFQADdUNBUNhYFD2jC4cN2nRcMQJeg4Ej0GQVuhojztHAEXQALx0SQgADMhAAjI8QNIANraaiUOAAXWkZ3QXB4fBgmGimAgXVEwzV2roAHImeheDAA9IQwxol0AI5nL1u6IAaxgpGien0in9AYA7qhLuH0DQIIpWGxorg1ZRKBB7B6YOIWSJKP69VbeHqngBfF56X0wABi0BgFDQWDwRDIIC7QA

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions