Skip to content

Commit 0c58d7b

Browse files
yonmilkKaratuss
andauthored
Fix is_unionable type_type check (#3852)
Co-Authored-By: Hyunmin Shin <shm1193@gmail.com>
1 parent 24c460b commit 0c58d7b

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

Lib/test/test_types.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -868,8 +868,6 @@ def forward_before(x: ForwardBefore[int]) -> None: ...
868868
assert typing.get_args(typing.get_type_hints(forward_after)['x']) == (int, Forward)
869869
assert typing.get_args(typing.get_type_hints(forward_before)['x']) == (int, Forward)
870870

871-
# TODO: RUSTPYTHON
872-
@unittest.expectedFailure
873871
def test_or_type_operator_with_Protocol(self):
874872
class Proto(typing.Protocol):
875873
def meth(self) -> int:
@@ -884,8 +882,6 @@ def test_or_type_operator_with_NamedTuple(self):
884882
NT=namedtuple('A', ['B', 'C', 'D'])
885883
assert NT | str == typing.Union[NT,str]
886884

887-
# TODO: RUSTPYTHON
888-
@unittest.expectedFailure
889885
def test_or_type_operator_with_TypedDict(self):
890886
class Point2D(typing.TypedDict):
891887
x: int

vm/src/builtins/union.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl PyUnion {
104104

105105
pub fn is_unionable(obj: PyObjectRef, vm: &VirtualMachine) -> bool {
106106
obj.class().is(vm.ctx.types.none_type)
107-
|| obj.class().is(vm.ctx.types.type_type)
107+
|| obj.payload_if_subclass::<PyType>(vm).is_some()
108108
|| obj.class().is(vm.ctx.types.generic_alias_type)
109109
|| obj.class().is(vm.ctx.types.union_type)
110110
}

0 commit comments

Comments
 (0)