Skip to content

Commit 3330b42

Browse files
authored
Fix ForwardRef comparison in test for Python 3.14 (#18885)
As a result of python/cpython#129465, `ForwardRef` only compare true in Python 3.14 if all attributes match.
1 parent 749f258 commit 3330b42

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

mypyc/test-data/run-tuples.test

+10-2
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,24 @@ class Inextensible(NamedTuple):
127127
x: int
128128

129129
[file driver.py]
130-
from typing import ForwardRef, Optional
130+
import sys
131+
from typing import Optional
131132
from native import ClassIR, FuncIR, Record
132133

134+
if sys.version_info >= (3, 14):
135+
from test.support import EqualToForwardRef
136+
type_forward_ref = EqualToForwardRef
137+
else:
138+
from typing import ForwardRef
139+
type_forward_ref = ForwardRef
140+
133141
assert Record.__annotations__ == {
134142
'st_mtime': float,
135143
'st_size': int,
136144
'is_borrowed': bool,
137145
'hash': str,
138146
'python_path': tuple,
139-
'type': ForwardRef('ClassIR'),
147+
'type': type_forward_ref('ClassIR'),
140148
'method': FuncIR,
141149
'shadow_method': type,
142150
'classes': dict,

0 commit comments

Comments
 (0)