diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index ef6ddf617d..d314387d60 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -868,8 +868,6 @@ def forward_before(x: ForwardBefore[int]) -> None: ... assert typing.get_args(typing.get_type_hints(forward_after)['x']) == (int, Forward) assert typing.get_args(typing.get_type_hints(forward_before)['x']) == (int, Forward) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_or_type_operator_with_Protocol(self): class Proto(typing.Protocol): def meth(self) -> int: @@ -884,8 +882,6 @@ def test_or_type_operator_with_NamedTuple(self): NT=namedtuple('A', ['B', 'C', 'D']) assert NT | str == typing.Union[NT,str] - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_or_type_operator_with_TypedDict(self): class Point2D(typing.TypedDict): x: int diff --git a/vm/src/builtins/union.rs b/vm/src/builtins/union.rs index 813974b53c..58d9ae4dc8 100644 --- a/vm/src/builtins/union.rs +++ b/vm/src/builtins/union.rs @@ -104,7 +104,7 @@ impl PyUnion { pub fn is_unionable(obj: PyObjectRef, vm: &VirtualMachine) -> bool { obj.class().is(vm.ctx.types.none_type) - || obj.class().is(vm.ctx.types.type_type) + || obj.payload_if_subclass::(vm).is_some() || obj.class().is(vm.ctx.types.generic_alias_type) || obj.class().is(vm.ctx.types.union_type) }