This code should be accepted by mypy: ``` python def f(x: Union[int, str]) -> None: assert isinstance(x, int) x + 1 # type of x is int, so this should be okay ``` The type type checker should know about type assertions.
Activity
JukkaL commentedon Oct 12, 2014
This could sometimes be used as an arguably more Pythonic replacement for casts.
gvanrossum commentedon Mar 23, 2016
I found a bunch of occurrences of this in our server code; bumping priority to 0.3.2.
Get type information from isinstance assertions
Get type information from isinstance assertions (#1346)