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: Generator[YieldType], where the other arguments default to None. This makes the common case more readable and is less error-prone. (I always forget the second and third argument, since that use case is so uncommon for me.)
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.
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 not a real solution for the general case. I still believe that Generator should be usable with just one argument or typing should provide such an alias.
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, that makes a mockery of the whole process. You might as well set everything to Any.