{"record":{"id":"b5929ff20a27fe4a","repo":"astral-sh/ruff","slug":"expected-at-least-one-argument-in-outer-function-c","errorCode":null,"errorMessage":"Expected at least one argument in outer function call","messagePattern":"Expected at least one argument in outer function call","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs","lineNumber":568,"sourceCode":"    outer_call.args = match outer_call.args.split_first() {\n        Some((first, rest)) => {\n            let inner_call = match_call(&first.value)?;\n            if let Some(arg) = inner_call\n                .args\n                .iter()\n                .find(|argument| argument.keyword.is_none())\n            {\n                let mut arg = arg.clone();\n                arg.comma.clone_from(&first.comma);\n                arg.whitespace_after_arg = first.whitespace_after_arg.clone();\n                iter::once(arg)\n                    .chain(rest.iter().cloned())\n                    .collect::<Vec<_>>()\n            } else {\n                rest.to_vec()\n            }\n        }\n        None => bail!(\"Expected at least one argument in outer function call\"),\n    };\n\n    Ok(Edit::range_replacement(\n        tree.codegen_stylist(stylist),\n        expr.range(),\n    ))\n}\n\n/// (C416) Convert `[i for i in x]` to `list(x)`.\npub(crate) fn fix_unnecessary_comprehension(\n    expr: &Expr,\n    locator: &Locator,\n    stylist: &Stylist,\n) -> Result<Edit> {\n    let module_text = locator.slice(expr);\n    let mut tree = match_expression(module_text)?;\n\n    match &tree {","sourceCodeStart":550,"sourceCodeEnd":586,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs#L550-L586","documentation":"Raised by the C418/unnecessary-double-cast-or-process fix (e.g. `list(tuple(x))`, `set(list(x))`) when the outer call has no arguments at all. The fixer needs at least the inner argument to rebuild the simplified call; with zero arguments it bails.","triggerScenarios":"`ruff check --fix` on a call like `list()` matched against the double-cast rule, or a stale diagnostic whose ranges no longer line up with the edited source.","commonSituations":"Applying cached/stale diagnostics to changed code; unusual constructs like `list(*args)` that parsed into an argument shape the fixer did not expect.","solutions":["Re-run ruff so the fix operates on fresh diagnostics.","Rewrite manually: `list()` has no double-cast to remove; keep it as-is.","Suppress the fix and keep only the diagnostic if the call is intentionally empty."],"exampleFix":"// before\nlist(tuple(items))\n// after\nlist(items)","handlingStrategy":"validation","validationCode":"assert bool(cast_call.args), 'C418 fix needs at least one argument'","typeGuard":"def has_args(expr):\n    return isinstance(expr, ast.Call) and len(expr.args) >= 1","tryCatchPattern":"try:\n    apply_autofix(diagnostic)\nexcept Exception:\n    keep_code_as_is()","preventionTips":["Don't feed empty calls like list()/set() to the double-cast fix","Refresh diagnostics before fixing","Rewrite nested casts manually when shapes are unusual"],"tags":["rust","ruff","lint-autofix","flake8-comprehensions"],"backgroundTag":"stale-diagnostic-ast-mismatch","analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}