Zeth added the comment:
I don't get why this is closed. It is a bug. The Generator type annotation
works differently than the others, it shouldn't.
Sebastian Rittau is correct here, the closer doesn't seem to have understood.
As for using Iterator instead as the documentation suggests,
Sebastian Rittau added the comment:
Sorry for not responding, but I didn't know what I could have added that I
didn't already say in the opening post. Of course, you can use workaround like
using the three-argument version or creating aliases. Using Iterator is of
course
Ivan Levkivskyi added the comment:
Since there is no response for few weeks I assume this works for you.
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker
Ivan Levkivskyi 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
New submission from Sebastian Rittau :
Currently typing.Generator requires three arguments: Generator[YieldType,
SendType, ReturnType].
At least for me, passing values to a generator is a very rare case. I suggest
to allow only one argument to be passed to Generator: