Closed
Description
In the following example, the branch of an if-statement is not being typechecked.
class Parent1: pass
class Parent2: pass
class Child(Parent1, Parent2): pass
def goo(p: Parent1) -> None:
if isinstance(p, Parent2):
# this branch is not typechecked
1 + 'boom' # no error from mypy here.
goo(Child())
Here is the output from mypy
and python
.
$ mypy i.py
$ python3 i.py
Traceback (most recent call last):
File "i.py", line 13, in <module>
goo(Child())
File "i.py", line 10, in goo
1 + 'boom' # no error from mypy but there's an error at runtime
TypeError: unsupported operand type(s) for +: 'int' and 'str'