Skip to content

Commit 5563d05

Browse files
fix: use Optional instead of |
1 parent 8f5bf72 commit 5563d05

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

mypyc/test-data/run-weakref.test

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from weakref import proxy, ref
66
from mypy_extensions import mypyc_attr
77
from testutil import assertRaises
8+
from typing import Optional
89

910
@mypyc_attr(native_class=False)
1011
class Object:
@@ -15,22 +16,22 @@ class Object:
1516
_callback_called_cache = {"ref": False, "proxy": False}
1617

1718
def test_weakref_ref() -> None:
18-
obj: Object | None = Object()
19+
obj: Optional[Object] = Object()
1920
r = ref(obj)
2021
assert r() is obj
2122
obj = None
2223
assert r() is None, r()
2324

2425
def test_weakref_ref_with_callback() -> None:
25-
obj: Object | None = Object()
26+
obj: Optional[Object] = Object()
2627
r = ref(obj, lambda x: _callback_called_cache.__setitem__("ref", True))
2728
assert r() is obj
2829
obj = None
2930
assert r() is None, r()
3031
assert _callback_called_cache["ref"] is True
3132

3233
def test_weakref_proxy() -> None:
33-
obj: Object | None = Object()
34+
obj: Optional[Object] = Object()
3435
p = proxy(obj)
3536
assert obj.some_meth() == 1
3637
assert p.some_meth() == 1
@@ -40,7 +41,7 @@ def test_weakref_proxy() -> None:
4041
p.some_meth()
4142

4243
def test_weakref_proxy_with_callback() -> None:
43-
obj: Object | None = Object()
44+
obj: Optional[Object] = Object()
4445
p = proxy(obj, lambda x: _callback_called_cache.__setitem__("proxy", True))
4546
assert obj.some_meth() == 1
4647
assert p.some_meth() == 1

0 commit comments

Comments
 (0)