Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overloaded functions cause reportIncompatibleMethodOverride during multiple inheritance #9625

Open
neerajanil opened this issue Dec 24, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@neerajanil
Copy link

Describe the bug
During multiple inheritance if both base classes implement the same method with the same override signatures, it will still throw a reportIncompatibleMethodOverride error on the child class. mypy does not throw an error for the same code.
pyright playground
mypy playground

Code

from typing import overload, Union, List

class Super:
    
    @overload
    def method(self, x: int) -> int:
        ...
        
    @overload
    def method(self, x: str) -> str:
        ...
        
    def method(self, x: Union[int, str]) -> Union[int, str]:
        return x
    
class Sub1(Super):
    @overload
    def method(self, x: int) -> int:
        ...
        
    @overload
    def method(self, x: str) -> str:
        ...
        
    def method(self, x: Union[int, str]) -> Union[int, str]:
        return x

class Sub2(Super):
    @overload
    def method(self, x: int) -> int:
        ...
        
    @overload
    def method(self, x: str) -> str:
        ...
        
    def method(self, x: Union[int, str]) -> Union[int, str]:
        return x


class Sub3(Sub1, Sub2): # reportIncompatibleMethodOverride reported here
    ...

VS Code extension or command-line
Running pyright CLI version 1.1.391

@neerajanil neerajanil added the bug Something isn't working label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant