Skip to content

Fix is_unionable type_type check #3852

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 4 commits into from
Jul 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 0 additions & 4 deletions Lib/test/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion vm/src/builtins/union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<PyType>(vm).is_some()
|| obj.class().is(vm.ctx.types.generic_alias_type)
|| obj.class().is(vm.ctx.types.union_type)
}
Expand Down