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

Function format_missing_args

crates/vm/src/builtins/function.rs:30–59  ·  view source on GitHub ↗
(
    qualname: impl core::fmt::Display,
    kind: &str,
    missing: &mut Vec<impl core::fmt::Display>,
)

Source from the content-addressed store, hash-verified

28use rustpython_jit::CompiledCode;
29
30fn format_missing_args(
31 qualname: impl core::fmt::Display,
32 kind: &str,
33 missing: &mut Vec<impl core::fmt::Display>,
34) -> String {
35 let count = missing.len();
36 let last = if missing.len() > 1 {
37 missing.pop()
38 } else {
39 None
40 };
41 let (and, right): (&str, String) = if let Some(last) = last {
42 (
43 if missing.len() == 1 {
44 "' and '"
45 } else {
46 "', and '"
47 },
48 format!("{last}"),
49 )
50 } else {
51 ("", String::new())
52 };
53 format!(
54 "{qualname}() missing {count} required {kind} argument{}: '{}{}{right}'",
55 if count == 1 { "" } else { "s" },
56 missing.iter().join("', '"),
57 and,
58 )
59}
60
61#[pyclass(module = false, name = "function", traverse = "manual")]
62#[derive(Debug)]

Callers 1

fill_locals_from_argsMethod · 0.85

Calls 3

newFunction · 0.85
lenMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected