Skip to content
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

Phase 2 of async/await #1946

Merged
merged 23 commits into from
Aug 3, 2016
Merged

Phase 2 of async/await #1946

merged 23 commits into from
Aug 3, 2016

Conversation

gvanrossum
Copy link
Member

This PR adds support for decorating either generators or async def functions with @types.coroutine or @asyncio.coroutine. This will fix #1453.

@@ -61,6 +62,9 @@ class Awaitable(Generic[T]):
@abstractmethod
def __await__(self) -> Generator[Any, Any, T]: pass

class AwaitableGenerator(Generator[T, U, V], Awaitable[V], Generic[T, U, V, S]):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there an AwaitableGenerator in the test data typing stub when there isn't one in the real typing module?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this stub (despite its extension) is actually a stub. It matches the real typing.pyi, not any real typing.py.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh okay. That makes sense.

self.lookup_qualified('typing.AwaitableGenerator')
except KeyError:
return False
agt = self.named_generic_type('typing.AwaitableGenerator',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be simpler to just look at the fullname instead, like we do elsewhere?

else:
# `return_type` is a supertype of Generator, so callers won't be able to send it
# values.
# Supertype of Generator (Iterator, Iterable, object), tc is None.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the bit of motivation is worthwhile here too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ddfisher ddfisher merged commit 340d34e into master Aug 3, 2016
@ddfisher ddfisher deleted the add-crawl2-reborn branch August 3, 2016 23:57
@ddfisher
Copy link
Collaborator

ddfisher commented Aug 3, 2016

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support PEP 492 syntax
2 participants