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

Closed
neerajanil opened this issue Dec 24, 2024 · 2 comments
Labels
addressed in next version Issue is fixed and will appear in next published version 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
erictraut added a commit that referenced this issue Jan 14, 2025
…rror when two subclasses with an overloaded method are combined using multiple inheritance. This addresses #9625.
erictraut added a commit that referenced this issue Jan 14, 2025
…rror when two subclasses with an overloaded method are combined using multiple inheritance. This addresses #9625. (#9700)
@erictraut
Copy link
Collaborator

Thanks for the bug report. This will be addressed in the next release.

@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Jan 14, 2025
@erictraut
Copy link
Collaborator

This is addressed in pyright 1.1.392.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants