Skip to content

Commit

Permalink
Fix tests on 3.13.0a5 (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra authored Mar 14, 2024
1 parent 8170fc7 commit 10648b6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased

- Fix tests on 3.13.0a5. Patch by Jelle Zijlstra.
- Fix the runtime behavior of type parameters with defaults (PEP 696).
Patch by Nadir Chowdhury.
- Fix minor discrepancy between error messages produced by `typing`
Expand Down
2 changes: 1 addition & 1 deletion src/test_typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5531,7 +5531,7 @@ def test_typing_extensions_defers_when_possible(self):
}
if sys.version_info < (3, 13):
exclude |= {'NamedTuple', 'Protocol', 'runtime_checkable'}
if not hasattr(typing, 'ReadOnly'):
if not typing_extensions._PEP_728_IMPLEMENTED:
exclude |= {'TypedDict', 'is_typeddict'}
for item in typing_extensions.__all__:
if item not in exclude and hasattr(typing, item):
Expand Down
9 changes: 7 additions & 2 deletions src/typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,11 @@ def inner(func):
return inner


if hasattr(typing, "ReadOnly"):
# Update this to something like >=3.13.0b1 if and when
# PEP 728 is implemented in CPython
_PEP_728_IMPLEMENTED = False

if _PEP_728_IMPLEMENTED:
# The standard library TypedDict in Python 3.8 does not store runtime information
# about which (if any) keys are optional. See https://bugs.python.org/issue38834
# The standard library TypedDict in Python 3.9.0/1 does not honour the "total"
Expand All @@ -803,7 +807,8 @@ def inner(func):
# Aaaand on 3.12 we add __orig_bases__ to TypedDict
# to enable better runtime introspection.
# On 3.13 we deprecate some odd ways of creating TypedDicts.
# PEP 705 proposes adding the ReadOnly[] qualifier.
# Also on 3.13, PEP 705 adds the ReadOnly[] qualifier.
# PEP 728 (still pending) makes more changes.
TypedDict = typing.TypedDict
_TypedDictMeta = typing._TypedDictMeta
is_typeddict = typing.is_typeddict
Expand Down

0 comments on commit 10648b6

Please sign in to comment.