Skip to content

Fix tests on Python 3.14 #592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 5, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix a7?
  • Loading branch information
JelleZijlstra committed May 5, 2025
commit 34293d775b66bc6c6370b517d11f80719fb4d316
14 changes: 9 additions & 5 deletions src/test_typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@
runtime_checkable,
)

if sys.version_info >= (3, 14):
from test.support import EqualToForwardRef
else:
EqualToForwardRef = typing.ForwardRef

NoneType = type(None)
T = TypeVar("T")
KT = TypeVar("KT")
Expand Down Expand Up @@ -5164,7 +5169,6 @@ class Y(TypedDict):
b: "int"
if sys.version_info >= (3, 14):
import annotationlib
from test.support import EqualToForwardRef

fwdref = EqualToForwardRef('int', module=__name__)
self.assertEqual(Y.__annotations__, {'a': type(None), 'b': fwdref})
Expand Down Expand Up @@ -6022,7 +6026,7 @@ def test_substitution(self):
U2 = Unpack[Ts]
self.assertEqual(C2[U1], (str, int, str))
self.assertEqual(C2[U2], (str, Unpack[Ts]))
self.assertEqual(C2["U2"], (str, typing.ForwardRef("U2")))
self.assertEqual(C2["U2"], (str, EqualToForwardRef("U2")))

if (3, 12, 0) <= sys.version_info < (3, 12, 4):
with self.assertRaises(AssertionError):
Expand Down Expand Up @@ -7309,8 +7313,8 @@ def test_or(self):
self.assertEqual(X | "x", Union[X, "x"])
self.assertEqual("x" | X, Union["x", X])
# make sure the order is correct
self.assertEqual(get_args(X | "x"), (X, typing.ForwardRef("x")))
self.assertEqual(get_args("x" | X), (typing.ForwardRef("x"), X))
self.assertEqual(get_args(X | "x"), (X, EqualToForwardRef("x")))
self.assertEqual(get_args("x" | X), (EqualToForwardRef("x"), X))

def test_union_constrained(self):
A = TypeVar('A', str, bytes)
Expand Down Expand Up @@ -8878,7 +8882,7 @@ class X:
type_params=None,
format=Format.FORWARDREF,
)
self.assertEqual(evaluated_ref, typing.ForwardRef("doesnotexist2"))
self.assertEqual(evaluated_ref, EqualToForwardRef("doesnotexist2"))

def test_evaluate_with_type_params(self):
# Use a T name that is not in globals
Expand Down
Loading