mirror of https://github.com/astral-sh/ruff
F401 sort bindings before adding to __all__ (#11648)
Sort the binding IDs before passing them to the add-to-`__all__` function to address #11619.
This commit is contained in:
parent
27f6f048f0
commit
e914bc300b
|
|
@ -330,7 +330,7 @@ pub(crate) fn unused_import(checker: &Checker, scope: &Scope, diagnostics: &mut
|
|||
fix_by_reexporting(
|
||||
checker,
|
||||
import_statement,
|
||||
&to_reexport.iter().map(|(b, _)| b).collect::<Vec<_>>(),
|
||||
to_reexport.iter().map(|(b, _)| b).collect::<Vec<_>>(),
|
||||
&dunder_all_exprs,
|
||||
)
|
||||
.ok(),
|
||||
|
|
@ -450,7 +450,7 @@ fn fix_by_removing_imports<'a>(
|
|||
fn fix_by_reexporting(
|
||||
checker: &Checker,
|
||||
node_id: NodeId,
|
||||
imports: &[&ImportBinding],
|
||||
mut imports: Vec<&ImportBinding>,
|
||||
dunder_all_exprs: &[&ast::Expr],
|
||||
) -> Result<Fix> {
|
||||
let statement = checker.semantic().statement(node_id);
|
||||
|
|
@ -458,6 +458,8 @@ fn fix_by_reexporting(
|
|||
bail!("Expected import bindings");
|
||||
}
|
||||
|
||||
imports.sort_by_key(|b| b.name);
|
||||
|
||||
let edits = match dunder_all_exprs {
|
||||
[] => fix::edits::make_redundant_alias(
|
||||
imports.iter().map(|b| b.import.member_name()),
|
||||
|
|
|
|||
Loading…
Reference in New Issue