Closed
Description
mypy version: 0.511
python version: 3.6.1
Given this valid program:
from typing import Iterator
def stringify(it: Iterator[int]) -> Iterator[str]:
return (f"{x}" for x in it)
def stringify2(it: Iterator[int]) -> Iterator[str]:
for x in it:
yield f"{x}"
def stringify3(it: Iterator[int]) -> Iterator[str]:
return (str(x) for x in it)
def stringify4(it: Iterator[int]) -> Iterator[str]:
for x in it:
yield str(x)
I get errors for the first two variations:
foo.py:4: error: Generator has incompatible item type "int"
foo.py:8: error: Incompatible types in yield (actual type "int", expected type "str")
It seems that mypy doesn't recognize that fstrings are produce a str
. Interestingly, the yield error didn't show up in my old mypy version 0.501.
Metadata
Metadata
Assignees
Labels
No labels