-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add AsyncGenerator #346
add AsyncGenerator #346
Conversation
Thanks! I will merge this after 3.5.3 has been released. |
And yes, please send a separate doc patch. |
This parallels python/typing#346
This parallels python/typing#346
extra=_AG_base): | ||
__slots__ = () | ||
|
||
def __new__(cls, *args, **kwds): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you always inherit from collections.abc
there is no need to override __new__
. It will be anyway not possible to instantiate typing.AsyncGenerator
because collections.abc.AsyncGenerator
has abstract methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was mostly copied from the Generator
implementation just above. It is possible to instantiate a subclass of AsyncGenerator
, which would use this __new__
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I understand your point. The only way to instantiate a subclass of an ABC is to implement all abstract methods. Moreover, there is no way a subclass could "use" this __new__
, it only exists everywhere in typing
to prohibit direct instantiation of generic version of concrete collections and similar things.
__new__
for Generator
is necessary, since it could inherit from types.GeneratorType
.
@@ -1320,6 +1320,7 @@ def blah(): | |||
|
|||
|
|||
ASYNCIO = sys.version_info[:2] >= (3, 5) | |||
ASYNC_GENERATOR = sys.version_info[:2] >= (3, 6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this line needed? The variable is not used AFAICT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, looks like I didn't end up needing it. I'll remove it.
2a8f9ed
to
f4bd52f
Compare
@ilevkivskyi Are you happy with this code now? Then I can merge it. (Honestly I want to give you commit privs here if you don't already have them.) |
There are two very minor points: the variable
I am glad that you trust me. I don't have the privileges. I think it indeed may simplify things. |
I invited you. Go ahead and commit this PR when you are happy with it. |
Probably the best way is to merge this now and I will add those minor changes myself, so that #355 will be "unblocked" very soon. |
This parallels python/typing#346
…/__init__.pyi (#815) This parallels python/typing#346
Looks like this was inadvertently omitted from 3.6 as released.
Should I submit a separate patch to CPython directly to add documentation?