mirror of https://github.com/python/cpython
gh-126699: allow AsyncIterator to be used as a base for Protocols (#126702)
This commit is contained in:
parent
0052a8c638
commit
feb3e0b19c
|
@ -4255,6 +4255,9 @@ class ProtocolTests(BaseTestCase):
|
|||
class CustomContextManager(typing.ContextManager, Protocol):
|
||||
pass
|
||||
|
||||
class CustomAsyncIterator(typing.AsyncIterator, Protocol):
|
||||
pass
|
||||
|
||||
def test_non_runtime_protocol_isinstance_check(self):
|
||||
class P(Protocol):
|
||||
x: int
|
||||
|
|
|
@ -1940,7 +1940,8 @@ def _allow_reckless_class_checks(depth=2):
|
|||
_PROTO_ALLOWLIST = {
|
||||
'collections.abc': [
|
||||
'Callable', 'Awaitable', 'Iterable', 'Iterator', 'AsyncIterable',
|
||||
'Hashable', 'Sized', 'Container', 'Collection', 'Reversible', 'Buffer',
|
||||
'AsyncIterator', 'Hashable', 'Sized', 'Container', 'Collection',
|
||||
'Reversible', 'Buffer',
|
||||
],
|
||||
'contextlib': ['AbstractContextManager', 'AbstractAsyncContextManager'],
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Allow :class:`collections.abc.AsyncIterator` to be a base for Protocols.
|
Loading…
Reference in New Issue