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

Function empty_arguments_object

crates/vm/src/stdlib/_ast.rs:318–337  ·  view source on GitHub ↗

Create an empty `arguments` AST node (no parameters).

(vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

316
317/// Create an empty `arguments` AST node (no parameters).
318fn empty_arguments_object(vm: &VirtualMachine) -> PyObjectRef {
319 let node = NodeAst
320 .into_ref_with_type(vm, pyast::NodeArguments::static_type().to_owned())
321 .unwrap();
322 let dict = node.as_object().dict().unwrap();
323 for list_field in [
324 "posonlyargs",
325 "args",
326 "kwonlyargs",
327 "kw_defaults",
328 "defaults",
329 ] {
330 dict.set_item(list_field, vm.ctx.new_list(vec![]).into(), vm)
331 .unwrap();
332 }
333 for none_field in ["vararg", "kwarg"] {
334 dict.set_item(none_field, vm.ctx.none(), vm).unwrap();
335 }
336 node.into()
337}
338
339#[cfg(feature = "parser")]
340pub(crate) fn parse(

Callers 1

ast_to_objectMethod · 0.85

Calls 8

into_ref_with_typeMethod · 0.80
new_listMethod · 0.80
noneMethod · 0.80
unwrapMethod · 0.45
to_ownedMethod · 0.45
dictMethod · 0.45
as_objectMethod · 0.45
set_itemMethod · 0.45

Tested by

no test coverage detected