X Tutup
The Wayback Machine - https://web.archive.org/web/20201019100855/https://github.com/python/typing/issues/720
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

Defining subprotocols with AsyncContextManager in python < 3.8 raises a TypeError #720

Open
HeavenVolkoff opened this issue May 1, 2020 · 0 comments

Comments

@HeavenVolkoff
Copy link

@HeavenVolkoff HeavenVolkoff commented May 1, 2020

Creating a subprotocol with AsyncContextManager in python 3.8 works properly:

from typing_extensions import Protocol, AsyncContextManager

class Example(AsyncContextManager, Protocol):
    test: str

However in python < 3.8 (Actually only tested in Python 3.6 and 3.7) the above raises a TypeError:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/abc.py", line 126, in __new__
    cls = super().__new__(mcls, name, bases, namespace, **kwargs)
  File "/usr/local/lib/python3.7/typing.py", line 847, in __init_subclass__
    super().__init_subclass__(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/typing_extensions.py", line 1541, in __init_subclass__
    ' protocols, got %r' % base)
TypeError: Protocols can only inherit from other protocols, got <class 'contextlib.AbstractAsyncContextManager'>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.
X Tutup