pytypes
pytypes copied to clipboard
Generator expression is not considered Iterable
The following code:
from typing import Iterable
from pytypes import TypeChecker
def f(a: Iterable[str]) -> None:
pass
with TypeChecker():
f((c for c in 'abc'))
print("OK")
fails as follows:
$ python3 Test.py
Traceback (most recent call last):
File "Test.py", line 9, in <module>
f((c for c in 'abc'))
File "Test.py", line 5, in f
def f(a: Iterable[str]) -> None:
pytypes.exceptions.InputTypeError:
__main__.f
called with incompatible types:
Expected: Tuple[Iterable[str]]
Received: Tuple[Generator]