For instance, this script passes mypy:
importcontextlibfromtypingimportIterator@contextlib.contextmanagerdeff() ->Iterator[int]:
returniter([1])
withf():
passwithf():
raiseTypeError('wat')but fails at runtime (and not in the expected way):
$ python t.py Traceback (most recent call last): File "t.py", line 14, in <module> raise TypeError('wat')TypeError: watDuring handling of the above exception, another exception occurred:Traceback (most recent call last): File "t.py", line 14, in <module> raise TypeError('wat') File "/usr/lib/python3.6/contextlib.py", line 99, in __exit__ self.gen.throw(type, value, traceback)AttributeError: 'list_iterator' object has no attribute 'throw'
For instance, this script passes mypy:
but fails at runtime (and not in the expected way):