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

Add missing asyncio 3.7 top-level functions #2320

Merged
merged 5 commits into from
Jul 20, 2018
Merged

Add missing asyncio 3.7 top-level functions #2320

merged 5 commits into from
Jul 20, 2018

Conversation

hynek
Copy link
Member

@hynek hynek commented Jul 11, 2018

Here’s a first take at #2313

I couldn’t get the pytype tests running because it looks for my Python in /opt/python/3.6/bin/ (!?) so let’s see what Travis has to say…

@hynek
Copy link
Member Author

hynek commented Jul 11, 2018

I don’t quite understand the error message(s)…should I protect the definition against <3.7? But you don’t test against 3.7, do you?

@JelleZijlstra
Copy link
Member

Yes, you should put all new functions if sys.version_info >= (3, 7): blocks.

The Python versions that appear in Travis results are misleading; it's the Python versions we use to run the tools that perform the tests (mypy and pytype), not the Python version we check the stubs for.

@hynek
Copy link
Member Author

hynek commented Jul 14, 2018

I think I got it? Sadly right after the release of mypy 0.620. :(

off-topic: I wonder if there’s a way to use them and still run mypy in strict mode? # type: ignore only gives me a warning, that it was…ignored. :|

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thanks! Left a few comments.

if sys.version_info >= (3, 7):
def all_tasks(loop: Optional[AbstractEventLoop] = ...) -> Set[Task]: ...
def create_task(coro: Union[Generator[Any, None, _T], Awaitable[_T]]) -> Task: ...
def current_task(loop: Optional[AbstractEventLoop] = ...) -> Task: ...
Copy link
Member

Choose a reason for hiding this comment

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

Should return Optional[Task] I think.

@@ -0,0 +1,6 @@
from typing import Awaitable, TypeVar
Copy link
Member

Choose a reason for hiding this comment

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

Should wrap the entirety of this file in sys.version_info >= (3, 7) so that people trying to use this before 3.7 get an error.

@JelleZijlstra
Copy link
Member

Not sure what you are doing to get unused type-ignore warnings. You should be able to use these functions and then # type: ignore the lines where they're used.

@hynek
Copy link
Member Author

hynek commented Jul 20, 2018

I believe I’ve addressed everything.

@hynek
Copy link
Member Author

hynek commented Jul 20, 2018

(FWIW, wouldn’t it be kind of nicer to manually raise an ImportError instead of putting the whole module into a block?)

@JelleZijlstra
Copy link
Member

Yes, there has been talk of adding support for that suggestion (I think on the typing issue tracker?), but currently it's not supported.

Code looks good now, so I'll merge it in. Thanks for contributing!

@JelleZijlstra JelleZijlstra merged commit 7bdf465 into python:master Jul 20, 2018
@hynek hynek deleted the asyncio-3.7-toplevel branch July 23, 2018 05:00
yedpodtrzitko pushed a commit to yedpodtrzitko/typeshed that referenced this pull request Jan 23, 2019
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.

2 participants