Closed
Description
I tried to check type comments, but it cannot parse "with" and "for" statement as below.
# Example 1
x = [] # type: List[Employee]
x, y, z = [], [], [] # type: List[int], List[int], List[str]
x, y, z = [], [], [] # type: (List[int], List[int], List[str])
x = [
1,
2,
] # type: List[int]
# Example 2
from contextlib import contextmanager
@contextmanager
def frobnicate():
yield 1
with frobnicate() as foo: # type: int
# Here foo is an int
...
# Example 3
points = [(1.0, 2.5)] # type: List[Tuple[float, float]]
for x, y in points: # type: float, float
# Here x and y are floats
...
$ mypy type_comments.py
type_comments.py:17: error: Parse error before "
54B5
int"
type_comments.py:23: error: Parse error before "float"