MCPcopy Index your code
hub / github.com/RustPython/RustPython / type_check

Function type_check

crates/vm/src/builtins/union.rs:205–215  ·  view source on GitHub ↗
(arg: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

203}
204
205fn type_check(arg: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyObjectRef> {
206 // Fast path to avoid calling into typing.py
207 if is_unionable(arg.clone(), vm) {
208 return Ok(arg);
209 }
210 let message_str: PyObjectRef = vm
211 .ctx
212 .new_str("Union[arg, ...]: each arg must be a type.")
213 .into();
214 call_typing_func_object(vm, "_type_check", (arg, message_str))
215}
216
217fn has_union_operands(a: PyObjectRef, b: PyObjectRef, vm: &VirtualMachine) -> bool {
218 let union_type = vm.ctx.types.union_type;

Callers 1

or_opFunction · 0.70

Calls 4

is_unionableFunction · 0.85
call_typing_func_objectFunction · 0.85
cloneMethod · 0.45
new_strMethod · 0.45

Tested by

no test coverage detected