Created
October 13, 2023 11:27
-
-
Save piotr-piatkowski/1f5a99fd0f167dc695cf7b540de849fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mypy t.py | |
t.py:16: error: Argument 1 of "foo" is incompatible with supertype "BaseTest"; supertype defines the argument type as "TBase" [override] | |
t.py:16: note: This violates the Liskov substitution principle | |
t.py:16: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides | |
Found 1 error in 1 file (checked 1 source file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from pydantic import BaseModel | |
class TBase: | |
pass | |
class TDerived(TBase): | |
pass | |
class BaseTest(BaseModel): | |
def foo(self, v: TBase) -> TBase: | |
return v | |
class DerivedTest(BaseTest): | |
def foo(self, v: TDerived) -> TDerived: | |
return v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment