mypy
mypy copied to clipboard
`issubclass` doesn't narrow metaclasses
class FooMetaclass(type):
pass
class Foo(metaclass=FooMetaclass):
pass
fm: FooMetaclass
reveal_type(fm) # note: Revealed type is "__main__.FooMetaclass"
if issubclass(fm, Foo):
reveal_type(fm) # note: Revealed type is "__main__.FooMetaclass"
https://mypy-play.net/?mypy=master&python=3.10&gist=d03a0fb47ada04cb3e352ed13fc0f58b
Also related:
class A:
pass
class B:
pass
t = A
if issubclass(t, B):
reveal_type(t) # Should be reported as unreachable, because `t` is never a subtype of `B`
But, this reveals: Revealed type is "def () -> ex.A"
I am going to look into it! Thanks!
Update: no, this is unrelated.
Any progress on this issue ?
Thanks for the ping, I've sent a PR.