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

Several types should not exist in Python < 3.5 #655

Closed
gvanrossum opened this issue Nov 4, 2016 · 2 comments
Closed

Several types should not exist in Python < 3.5 #655

gvanrossum opened this issue Nov 4, 2016 · 2 comments
Labels
stubs: false negative Type checkers do not report an error, but should

Comments

@gvanrossum
Copy link
Member

The typing module defines several types that should only exist for Python 3.5 and higher: Awaitable, AsyncIterator, AsyncIterable, Coroutine, Collection, ContextManager.

The types module also defines two: CoroutineType and coroutine.

Note that if we remove these for Python 3.4, the asyncio stubs need to be adjusted, since they currently reference these unconditionally (though only in overloads or unions used for arguments).

Also note that if we remove these, mypy starts crashing on async def with Python 3.4 or earlier; see python/mypy#2401.

JelleZijlstra added a commit to JelleZijlstra/typeshed that referenced this issue Apr 23, 2017
This fixes the easier part of python#655.

Would it make sense to add a generic typing.ContextManager that exists in any Python version?
@gvanrossum
Copy link
Member Author

For ContextManager specifically, we ended up deciding to make it official (see python/typing#274 and python/typing#422).

For the others I think there's still value in not defining types for Python versions that don't support them.

JelleZijlstra added a commit to JelleZijlstra/typeshed that referenced this issue May 6, 2017
This fixes the easier part of python#655.

Would it make sense to add a generic typing.ContextManager that exists in any Python version?
matthiaskramm pushed a commit that referenced this issue May 8, 2017
* add typing.ContextManager for 3.6+ only

This fixes the easier part of #655.

Would it make sense to add a generic typing.ContextManager that exists in any Python version?

* update comment

* fix argument types for ContextManager.__exit__

* add AsyncContextManager

* add @asynccontextmanager

* typing.ContextManager now always exists

* back out async-related changes

Will submit those in a separate PR later

* fix import order

* AbstractContextManager only exists in 3.6+

* AbstractContextManager -> ContextManager
li-dan pushed a commit to li-dan/typeshed that referenced this issue May 22, 2017
* add typing.ContextManager for 3.6+ only

This fixes the easier part of python#655.

Would it make sense to add a generic typing.ContextManager that exists in any Python version?

* update comment

* fix argument types for ContextManager.__exit__

* add AsyncContextManager

* add @asynccontextmanager

* typing.ContextManager now always exists

* back out async-related changes

Will submit those in a separate PR later

* fix import order

* AbstractContextManager only exists in 3.6+

* AbstractContextManager -> ContextManager
@srittau srittau added stubs: false positive Type checkers report false errors stubs: false negative Type checkers do not report an error, but should and removed stubs: false positive Type checkers report false errors labels Oct 28, 2018
@srittau
Copy link
Collaborator

srittau commented Oct 23, 2019

Closing this, since Python 3.4 is not supported anymore.

@srittau srittau closed this as completed Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: false negative Type checkers do not report an error, but should
Projects
None yet
Development

No branches or pull requests

2 participants