When I run list[()], I modify it so that list[()] comes out

This commit is contained in:
hwi-ya
2022-04-10 12:43:38 +09:00
parent 84e714bc56
commit 263aec1532

View File

@@ -98,17 +98,26 @@ impl PyGenericAlias {
}),
}
}
Ok(format!(
"{}[{}]",
repr_item(self.origin.as_object().to_owned(), vm)?,
self.args
.as_slice()
.iter()
.map(|o| repr_item(o.clone(), vm))
.collect::<PyResult<Vec<_>>>()?
.join(", ")
))
if self.args.len() == 0 {
Ok(format!(
"{}[{}]",
repr_item(self.origin.as_object().to_owned(), vm)?,
"()"
))
}
else {
Ok(format!(
"{}[{}]",
repr_item(self.origin.as_object().to_owned(), vm)?,
self.args
.as_slice()
.iter()
.map(|o| repr_item(o.clone(), vm))
.collect::<PyResult<Vec<_>>>()?
.join(", ")
))
}
}
#[pyproperty(magic)]