8000 Merge pull request #4253 from oow214/qualname_type · RustPython/RustPython@77b821a · GitHub
[go: up one dir, main page]

Skip to content

Commit 77b821a

Browse files
authored
Merge pull request #4253 from oow214/qualname_type
Fix `repr` for union
2 parents 835771b + cc809f3 commit 77b821a

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

Lib/test/test_types.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,8 +929,6 @@ def test_or_type_operator_with_SpecialForm(self):
929929
assert typing.Optional[int] | str == typing.Union[int, str, None]
930930
assert typing.Union[int, bool] | str == typing.Union[int, bool, str]
931931

932-
# TODO: RUSTPYTHON
933-
@unittest.expectedFailure
934932
def test_or_type_repr(self):
935933
assert repr(int | str) == "int | str"
936934
assert repr((int | str) | list) == "int | str | list"

vm/src/builtins/union.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl PyUnion {
4343
#[pymethod(magic)]
4444
fn repr(&self, vm: &VirtualMachine) -> PyResult<String> {
4545
fn repr_item(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<String> {
46-
if vm.is_none(&obj) {
46+
if obj.is(vm.ctx.types.none_type) {
4747
return Ok("None".to_string());
4848
}
4949

0 commit comments

Comments
 (0)
0