mypy icon indicating copy to clipboard operation
mypy copied to clipboard

stubtest: metaclass is not taken into an account

Open sobolevn opened this issue 3 years ago • 2 comments

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

sobolevn avatar Aug 04 '22 18:08 sobolevn

CC @AlexWaygood

sobolevn avatar Aug 04 '22 18:08 sobolevn

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

hauntsaninja avatar Aug 04 '22 19:08 hauntsaninja