Skip to content

Commit 10648b6

Browse files
Fix tests on 3.13.0a5 (#358)
1 parent 8170fc7 commit 10648b6

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Unreleased
22

3+
- Fix tests on 3.13.0a5. Patch by Jelle Zijlstra.
34
- Fix the runtime behavior of type parameters with defaults (PEP 696).
45
Patch by Nadir Chowdhury.
56
- Fix minor discrepancy between error messages produced by `typing`

src/test_typing_extensions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5531,7 +5531,7 @@ def test_typing_extensions_defers_when_possible(self):
55315531
}
55325532
if sys.version_info < (3, 13):
55335533
exclude |= {'NamedTuple', 'Protocol', 'runtime_checkable'}
5534-
if not hasattr(typing, 'ReadOnly'):
5534+
if not typing_extensions._PEP_728_IMPLEMENTED:
55355535
exclude |= {'TypedDict', 'is_typeddict'}
55365536
for item in typing_extensions.__all__:
55375537
if item not in exclude and hasattr(typing, item):

src/typing_extensions.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,11 @@ def inner(func):
792792
return inner
793793

794794

795-
if hasattr(typing, "ReadOnly"):
795+
# Update this to something like >=3.13.0b1 if and when
796+
# PEP 728 is implemented in CPython
797+
_PEP_728_IMPLEMENTED = False
798+
799+
if _PEP_728_IMPLEMENTED:
796800
# The standard library TypedDict in Python 3.8 does not store runtime information
797801
# about which (if any) keys are optional. See https://bugs.python.org/issue38834
798802
# The standard library TypedDict in Python 3.9.0/1 does not honour the "total"
@@ -803,7 +807,8 @@ def inner(func):
803807
# Aaaand on 3.12 we add __orig_bases__ to TypedDict
804808
# to enable better runtime introspection.
805809
# On 3.13 we deprecate some odd ways of creating TypedDicts.
806-
# PEP 705 proposes adding the ReadOnly[] qualifier.
810+
# Also on 3.13, PEP 705 adds the ReadOnly[] qualifier.
811+
# PEP 728 (still pending) makes more changes.
807812
TypedDict = typing.TypedDict
808813
_TypedDictMeta = typing._TypedDictMeta
809814
is_typeddict = typing.is_typeddict

0 commit comments

Comments
 (0)