-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
status: deferredIssue or PR deferred until some precondition is fixedIssue or PR deferred until some precondition is fixedstubs: false negativeType checkers do not report an error, but shouldType checkers do not report an error, but should
Description
For instance, this script passes mypy:
import contextlib
from typing import Iterator
@contextlib.contextmanager
def f() -> Iterator[int]:
return iter([1])
with f():
pass
with f():
raise TypeError('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: wat
During 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'
gschaffner, cj81499, crusaderky and graingert
Metadata
Metadata
Assignees
Labels
status: deferredIssue or PR deferred until some precondition is fixedIssue or PR deferred until some precondition is fixedstubs: false negativeType checkers do not report an error, but shouldType checkers do not report an error, but should