You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make the 2 last parameters for typing.Generator optional #4221
error: "Generator" expects 3 type arguments, but 1 given
I can silence mypy by doing:
Generator[int, None, None]
But given that the majority of generators just yield, rarely return or send, I think it would make sense to allow the last 2 parameters to have a default value of None.
We are annotating the types, all three of them, yield send and return ;-) For everything else, there's Iterator.
While I don't think this is a compelling case since there's a solution that works perfectly well, I'm sympathetic to the idea of defaults for generic types in general. The forum to take that issue up is the typing-sig mailing list or https://github.com/python/typing, not here
Activity
emmatyping commentedon Nov 8, 2017
This issue is probably better suited to be discussed in the typing repo https://github.com/python/typing
JukkaL commentedon Nov 8, 2017
Is there a reason you can't use
Iterator[int]as the return type?zeth commentedon Dec 1, 2021
Because the type is a Generator. Are we annotating the types or not?
hauntsaninja commentedon Dec 1, 2021
We are annotating the types, all three of them, yield send and return ;-) For everything else, there's Iterator.
While I don't think this is a compelling case since there's a solution that works perfectly well, I'm sympathetic to the idea of defaults for generic types in general. The forum to take that issue up is the typing-sig mailing list or https://github.com/python/typing, not here