{"record":{"id":"edf75e3eec9b9f70","repo":"astral-sh/ruff","slug":"no-edits-to-make","errorCode":null,"errorMessage":"No edits to make","messagePattern":"No edits to make","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs","lineNumber":636,"sourceCode":"            .collect();\n        if imports.is_empty() {\n            bail!(\"Expected import bindings\");\n        }\n        imports.sort_unstable();\n        imports\n    };\n\n    let edits = match dunder_all_exprs {\n        [] => fix::edits::make_redundant_alias(imports.into_iter(), statement),\n        [dunder_all] => {\n            fix::edits::add_to_dunder_all(imports.into_iter(), dunder_all, checker.stylist())\n        }\n        _ => bail!(\"Cannot offer a fix when there are multiple __all__ definitions\"),\n    };\n\n    // Only emit a fix if there are edits.\n    let mut tail = edits.into_iter();\n    let head = tail.next().ok_or(anyhow!(\"No edits to make\"))?;\n\n    let isolation = Checker::isolation(checker.semantic().parent_statement_id(node_id));\n    Ok(Fix::safe_edits(head, tail).isolate(isolation))\n}\n\n/// Returns an iterator over bindings to import statements that appear unused.\n///\n/// The stable behavior is to return those bindings to imports\n/// satisfying the following properties:\n///\n/// - they are not shadowed\n/// - they are not `global`, not `nonlocal`, and not explicit exports (i.e. `import foo as foo`)\n/// - they have no references, according to the semantic model\n///\n/// Under preview, there is a more refined analysis performed\n/// in the case where all bindings shadowed by a given import\n/// binding (including the binding itself) are of a simple form:\n/// they are required to be un-aliased imports or submodule imports.","sourceCodeStart":618,"sourceCodeEnd":654,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs#L618-L654","documentation":"This is an internal guard in Ruff's unused-import (F401) re-export fix. When an import is unused inside an `__init__.py` or re-export context, Ruff offers a fix that either makes the import a redundant alias (`import a as a`) or adds it to `__all__`. After computing the edit list, if it is unexpectedly empty the fixer raises 'No edits to make' instead of emitting a malformed empty fix.","triggerScenarios":"`fix_by_reexporting` runs for an unused import binding that qualifies for the re-export fix (e.g. in `__init__.py`), but the chosen edit generator (`make_redundant_alias` or `add_to_dunder_all`) returns an empty edit list for this statement layout.","commonSituations":"Autofixing unused imports in package `__init__.py` files with unusual `__all__` layouts or import forms; plugin authors consuming F401's fix see the Err instead of a Fix.","solutions":["Handle the Err gracefully and fall back to reporting the diagnostic without a fix (this is the library's intended behavior)","Manually re-export: change `import a` to `import a as a` or add the name to `__all__`","Report the snippet upstream if a plain `import a` in `__init__.py` still yields no fix"],"exampleFix":"# before (unused re-export)\nfrom pkg import thing\n# after (explicit re-export so F401 fix applies cleanly)\nfrom pkg import thing as thing\n# or\n__all__ = [\"thing\"]","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match fix_by_reexporting(...) {\n    Ok(fix) => Some(fix),\n    Err(e) if e.to_string().contains(\"No edits to make\") => None, // diagnostic only\n    Err(e) => return Err(e),\n}","preventionTips":["Keep exactly one `__all__` definition per `__init__.py`","Use explicit re-exports (`import a as a`) rather than relying on autofix","Handle fix-generation Errs as 'diagnostic without fix' by design"],"tags":["ruff","autofix","pyflakes","unused-import"],"backgroundTag":"autofix-generation-failed","analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}