mypy
mypy copied to clipboard
stubtest: metaclass is not taken into an account
Here's a simple example of this bug:
# runtime implementation
class A(type):
def method(self) -> None:
print('a')
class B(metaclass=A): ...
# This works:
# B.method()
And:
# type stub
class A(type):
def method(self) -> None: ...
class B: ... # notice that `metaclass=A` is missing, but `stubtest` does not produce any errors
Notice that this bug prevents using things like B.method() in your code.
I will send a fix asap.
Refs https://github.com/python/mypy/issues/13316
CC @AlexWaygood
Also note that stubtest currently doesn't check inheritance at all. I have a patch for this, but never got around to merging it. See https://github.com/python/typeshed/issues/3968 for the patch / details