(
_cls: crate::builtins::PyTypeRef,
args: PyObjectRef,
vm: &VirtualMachine,
)
| 172 | |
| 173 | #[pyclassmethod] |
| 174 | fn __class_getitem__( |
| 175 | _cls: crate::builtins::PyTypeRef, |
| 176 | args: PyObjectRef, |
| 177 | vm: &VirtualMachine, |
| 178 | ) -> PyResult { |
| 179 | // Convert args to tuple if not already |
| 180 | let args_tuple = if let Some(tuple) = args.downcast_ref::<PyTuple>() { |
| 181 | tuple.to_owned() |
| 182 | } else { |
| 183 | PyTuple::new_ref(vec![args], &vm.ctx) |
| 184 | }; |
| 185 | |
| 186 | // Check for empty union |
| 187 | if args_tuple.is_empty() { |
| 188 | return Err(vm.new_type_error("Cannot create empty Union")); |
| 189 | } |
| 190 | |
| 191 | // Create union using make_union to properly handle None -> NoneType conversion |
| 192 | make_union(&args_tuple, vm) |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | fn is_unionable(obj: PyObjectRef, vm: &VirtualMachine) -> bool { |
nothing calls this directly
no test coverage detected