mypy
mypy copied to clipboard
Need help annotating class with dynamic inheritance
To Reproduce
Gist URL: https://gist.github.com/mypy-play/d139ee55a5729d2ec5b63d4ceaeb5a33 Playground URL: https://mypy-play.net/?mypy=latest&python=3.12&gist=d139ee55a5729d2ec5b63d4ceaeb5a33
$ python test_mypy.py
header
1
header
2
$ mypy test_mypy.py
Warning: --strict-concatenate is deprecated; use --extra-checks instead
test_mypy.py:27: error: "__new__" must return a class instance (got "BaseClassT") [misc]
test_mypy.py:36: error: Unsupported argument 1 for "super" [misc]
test_mypy.py:38: error: Returning Any from function declared to return "BaseClassT" [no-any-return]
test_mypy.py:41: error: Non-overlapping identity check (left operand type: "type[BaseClassT]", right operand type: "type[Type1]") [comparison-overlap]
test_mypy.py:42: error: Returning Any from function declared to return "None" [no-any-return]
test_mypy.py:42: error: "Example[BaseClassT]" has no attribute "method1"; maybe "method"? [attr-defined]
test_mypy.py:43: error: Non-overlapping identity check (left operand type: "type[BaseClassT]", right operand type: "type[Type2]") [comparison-overlap]
test_mypy.py:44: error: Returning Any from function declared to return "None" [no-any-return]
test_mypy.py:44: error: "Example[BaseClassT]" has no attribute "method2"; maybe "method"? [attr-defined]
test_mypy.py:48: error: Missing type parameters for generic type "Example" [type-arg]
test_mypy.py:54: error: Cannot instantiate abstract class "ExampleSubclass" with abstract attribute "base_class" [abstract]
test_mypy.py:55: error: Cannot instantiate abstract class "ExampleSubclass" with abstract attribute "base_class" [abstract]
Found 12 errors in 1 file (checked 1 source file)