I have the following code. Class A contains a function f. Class B inherits from A and overrides this function. I also have protocol SupportsG which acts as a structural supertype to all classes implementing a function g. I have class B explicitly inherit this protocol:
from typing import Protocol
class SupportsG(Protocol):
def g(self) -> str: ...
class A:
def f(self) -> str:
return ""
class B(A, SupportsG):
def f(self) -> str:
return "test"
if __name__ == "__main__":
b = B()
My expectation here is that mypy would throw an error, because class B doesn't implement function g. However, if I run mypy --strict I get no errors.
What is the gap in my understanding here?