mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
[3.13] gh-126699: allow AsyncIterator to be used as a base for Protocols (GH-126702) (#126762)
gh-126699: allow AsyncIterator to be used as a base for Protocols (GH-126702)
(cherry picked from commit feb3e0b19c
)
Co-authored-by: Stephen Morton <github@tungol.org>
This commit is contained in:
parent
d9bbb52c7e
commit
a5672bec68
3 changed files with 6 additions and 1 deletions
|
@ -4254,6 +4254,9 @@ class ProtocolTests(BaseTestCase):
|
||||||
class CustomContextManager(typing.ContextManager, Protocol):
|
class CustomContextManager(typing.ContextManager, Protocol):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class CustomAsyncIterator(typing.AsyncIterator, Protocol):
|
||||||
|
pass
|
||||||
|
|
||||||
def test_non_runtime_protocol_isinstance_check(self):
|
def test_non_runtime_protocol_isinstance_check(self):
|
||||||
class P(Protocol):
|
class P(Protocol):
|
||||||
x: int
|
x: int
|
||||||
|
|
|
@ -1989,7 +1989,8 @@ def _allow_reckless_class_checks(depth=2):
|
||||||
_PROTO_ALLOWLIST = {
|
_PROTO_ALLOWLIST = {
|
||||||
'collections.abc': [
|
'collections.abc': [
|
||||||
'Callable', 'Awaitable', 'Iterable', 'Iterator', 'AsyncIterable',
|
'Callable', 'Awaitable', 'Iterable', 'Iterator', 'AsyncIterable',
|
||||||
'Hashable', 'Sized', 'Container', 'Collection', 'Reversible', 'Buffer',
|
'AsyncIterator', 'Hashable', 'Sized', 'Container', 'Collection',
|
||||||
|
'Reversible', 'Buffer',
|
||||||
],
|
],
|
||||||
'contextlib': ['AbstractContextManager', 'AbstractAsyncContextManager'],
|
'contextlib': ['AbstractContextManager', 'AbstractAsyncContextManager'],
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Allow :class:`collections.abc.AsyncIterator` to be a base for Protocols.
|
Loading…
Add table
Add a link
Reference in a new issue