Skip to content

Commit 680c822

Browse files
Allow all classes allowed in CPython 3.14
Also backport these to 3.13
1 parent 03ab4bd commit 680c822

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/typing_extensions.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,10 +614,11 @@ def __getitem__(self, params):
614614
_PROTO_ALLOWLIST = {
615615
'collections.abc': [
616616
'Callable', 'Awaitable', 'Iterable', 'Iterator', 'AsyncIterable',
617-
'AsyncIterator','Hashable', 'Sized', 'Container', 'Collection',
618-
'Reversible', 'Buffer'
617+
'AsyncIterator', 'Hashable', 'Sized', 'Container', 'Collection',
618+
'Reversible', 'Buffer',
619619
],
620620
'contextlib': ['AbstractContextManager', 'AbstractAsyncContextManager'],
621+
'io': ['Reader', 'Writer'],
621622
'typing_extensions': ['Buffer'],
622623
'os': ['PathLike'],
623624
}
@@ -655,8 +656,10 @@ def _caller(depth=1, default='__main__'):
655656

656657
# `__match_args__` attribute was removed from protocol members in 3.13,
657658
# we want to backport this change to older Python versions.
658-
# Breakpoint: https://github.com/python/cpython/pull/110683
659-
if sys.version_info >= (3, 13):
659+
# 3.14 additionally added `io.Reader`, `io.Writer` and `os.PathLike` to
660+
# the list of allowed non-protocol bases.
661+
# https://github.com/python/cpython/issues/127647
662+
if sys.version_info >= (3, 14):
660663
Protocol = typing.Protocol
661664
else:
662665
def _allow_reckless_class_checks(depth=2):

0 commit comments

Comments
 (0)