This code: ```python from typing import Union, Type class C: ... x: Union[C, Type[C]] if isinstance(x, type) and issubclass(x, C): reveal_type(x) ``` Shows that the type of `x` is `builtins.type`. Ideally it should be `Type[C]`.
Activity
andrewbaxter commentedon Apr 23, 2018
Is this the same as:
which fails with:
?
mypy 0.590
It looks like
issubclassdoesn't imply anything AFAICT, unlikeisinstance.There's this workaround:
but since this isn't in assertion format it seems more like a static check omission.
ilevkivskyi commentedon Apr 23, 2018
Yes, this is the same bug.
chadrik commentedon Jul 24, 2018
Just got bit by this one.
ilevkivskyi commentedon Dec 22, 2018
(Removing unions tag since there are repros without unions, and increasing priority to high since this appeared several times again.)
Fix interaction of isinstance() with Type[...] (#6419)