-
Notifications
You must be signed in to change notification settings - Fork 238
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
Support coroutines #119
Comments
The first style is better for The second style is more convenient for |
@vlasovskikh I agree. We also need
|
I like the latter style. I'm labeling this "enhancement" because I don't want this to derail the PEP approval process. FWIW we should distinguish between the return annotation (which can be |
Bumping this issue... Definitely not a high priority one, but it would be nice if we can have Awaitable and Coroutine types in the typing module. |
We will at some time, and we can add it in 3.5.1, but I'm still on vacation |
By the way, we discussed the second style of annotating coroutines with Andrew Svetlov at EuroPython. He liked the proposal, it looked natural to him. |
…coroutine type (PY-16094) It is suggested in python/typing#119 and most likely will become a part of PEP 484 after Python 3.5.
Now that Awaitable etc. are in typing.py, is there anything left to do in this project, or is the remaining task supporting async def etc. in mypy? That sounds like it would become fairly straightforward once the fast parser has really landed. Or do we need language in PEP 484 itself declaring that you should write async def foo() -> str:
return '' (referred to above as "the second style")? If you feel strongly we need PEP language then please propose some prose. FWIW Larry finally announced the 3.5.2 release schedule. |
I added PR #225 containing a short subsection discussing generators and coroutines in the PEP 484. |
Looks like the PEP work is done here, and so are the additions to typing.py. For mypy there's a separate bug: python/mypy#706 |
if anyone is listening to this thread, this was great for return types, but how about passing an unbound coroutine method as a parameter? From my searching it doesn't seem like there is a way to do it. It's actually a Callable[*]->Awaitable. It sounds like there should be a types.Coroutine. thanks! ex: async def dummy(dummy_param: int) -> Awaitable[None]:
return
async needs_typing(co_method):
await co_method(1)
await needs_typing(dummy) |
@thehesiod Yes, and there is an issue for this #251 |
Can we add support for coroutine functions? Mainly, I'm curious how we will annotate the return type. We basically have two options:
or
I'd really prefer the latter style. While the result of 'foo()' is a Coroutine, this is something that type checkers will know without a hint, what really matters is the expected result of
await foo()
expression.The text was updated successfully, but these errors were encountered: