-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add Async classes to typing stub. #30
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
Conversation
This is nice, but we first need to have the corresponding classes added to the non-stub typing.py. That code is in the CPython repo but also has its own little "upstream" repo: https://github.com/ambv/typehinting -- can you submit a PR for that repo too? (The typing.py module and its test are in the src directory; there python2 backport should not get this. But the added classes should be added to the PEP text in that repo too.) |
class AsyncIterator(AsyncIterable[_T_co], Generic[_T_co]): | ||
@abstractmethod | ||
def __anext__(self) -> Awaitable[_T_co]:... | ||
def __aiter__(self) -> 'AsyncIterator'[_T_co]:... |
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.
The quote should include []
, i.e. 'AsyncIterator[_T_co]'
.
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.
Done
@vlasovskikh Thanks for the feedback! I was thinking the API would be: async def f(x: int) -> Awaitable[int]:
await asyncio.sleep(x)
return x Similar to Hack's syntax - http://docs.hhvm.com/manual/en/hack.async.php Would that be workable with this implementation? |
@gvanrossum Coorisponding typehinting PR is python/typing#168 |
@rowillia This makes sense. Although python/typing#119 is still a valid request that proposes a shorter syntax. |
@vlasovskikh totally. AFAICT that's the syntax PyCharm is using right now, right? |
@rowillia Yes, we've adopted this syntax as an experiment since there are no awaitable/coroutine types right now in the typing module. |
Add Async classes to typing stub.
Thanks! Merged this and the typehinting changes. |
(And fixed by a4c268c.) |
No description provided.