Skip to content

Commit 559f96c

Browse files
Expand protocol allowlist to match CPythons
1 parent 9215c95 commit 559f96c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/test_typing_extensions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import io
1212
import itertools
1313
import pickle
14+
import os
1415
import re
1516
import subprocess
1617
import sys
@@ -3869,9 +3870,15 @@ def test_builtin_protocol_allowlist(self):
38693870
class CustomProtocol(TestCase, Protocol):
38703871
pass
38713872

3873+
class CustomPathLikeProtocol(os.PathLike, Protocol):
3874+
pass
3875+
38723876
class CustomContextManager(typing.ContextManager, Protocol):
38733877
pass
38743878

3879+
class CustomAsyncIterator(typing.AsyncIterator, Protocol):
3880+
pass
3881+
38753882
@skip_if_py312b1
38763883
def test_typing_extensions_protocol_allowlist(self):
38773884
@runtime_checkable

src/typing_extensions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,10 +614,12 @@ def __getitem__(self, params):
614614
_PROTO_ALLOWLIST = {
615615
'collections.abc': [
616616
'Callable', 'Awaitable', 'Iterable', 'Iterator', 'AsyncIterable',
617-
'Hashable', 'Sized', 'Container', 'Collection', 'Reversible', 'Buffer',
617+
'AsyncIterator','Hashable', 'Sized', 'Container', 'Collection',
618+
'Reversible', 'Buffer'
618619
],
619620
'contextlib': ['AbstractContextManager', 'AbstractAsyncContextManager'],
620621
'typing_extensions': ['Buffer'],
622+
'os': ['PathLike'],
621623
}
622624

623625

0 commit comments

Comments
 (0)