Ivan Levkivskyi <[email protected]> added the comment:
You can use Iterator type, for example this works in mypy (didn't test in other
type checkers):
def f() -> Iterator[int]:
yield 42
In case you want annotate something specifically as Generator[int, None, None]
(for example to use its .close() method), then you can create a generic alias:
T = TypeVar('T')
Gen = Generator[T, None, None]
def f() -> Gen[int]:
...
this is supported by mypy as well.
----------
nosy: +levkivskyi
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue31700>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com