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

Remove the reportImplicitOverride error when working with abstract classes or protocols. #986

Open
vlkorsakov opened this issue Jan 7, 2025 · 1 comment
Labels
awaiting response waiting for more info from the author - will eventually close if they don't respond type checking / linting issues relating to existing diagnostic rules or proposals for new diagnostic rules

Comments

@vlkorsakov
Copy link

vlkorsakov commented Jan 7, 2025

I think it’s a false positive. Basedpyright, like pyright, shows this error when I implement an abstract class or protocol:
Method "x" is not marked as override but is overriding a method in class "Interface"basedpyright[reportImplicitOverride](https://docs.basedpyright.com/v1.23.2/configuration/config-files/#reportImplicitOverride)

class Interface(Protocol):
    def x(self) -> None:
        raise NotImplementedError


class InterfaceABC(ABC):
    @abstractmethod
    def x(self) -> None:
        raise NotImplementedError


class Implementation(Interface):
    def x(self) -> None:
        ...


class ImplementationABC(Interface):
    def x(self) -> None:
        ...

Maybe, when I implement a protocol (abstract class) method or a method with the @abstractmethod decorator, basedpyright shouldn't show this error.

@DetachHead
Copy link
Owner

reportImplicitOverride is good at catching mistakes when renaming or removing methods. for example, if the x method was removed from InterfaceABC, you'd still want an error on ImplementationABC.x informing you that the method you're overriding/implementing no longer exists, which means it would probably never get called. so i think that rule should still be reported in cases like this

@DetachHead DetachHead added type checking / linting issues relating to existing diagnostic rules or proposals for new diagnostic rules awaiting response waiting for more info from the author - will eventually close if they don't respond labels Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response waiting for more info from the author - will eventually close if they don't respond type checking / linting issues relating to existing diagnostic rules or proposals for new diagnostic rules
Projects
None yet
Development

No branches or pull requests

2 participants