Skip to content

Commit

Permalink
change fix-title for redundant alias case to format itself and return…
Browse files Browse the repository at this point in the history
… early
  • Loading branch information
plredmond committed May 9, 2024
1 parent ec2d72d commit 1798425
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ impl Violation for UnusedImport {
Some(UnusedImportContext::Init {
first_party: true,
dunder_all_count: 0,
}) => "Use an explicit re-export",
}) => {
return Some(format!(
"Use an explicit re-export: `{binding} as {binding}`"
));
}
_ => "Remove unused import",
};
Some(if *multiple {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ __init__.py:33:15: F401 [*] `.unused` imported but unused; consider removing, ad
33 | from . import unused # F401: change to redundant alias
| ^^^^^^ F401
|
= help: Use an explicit re-export: `.unused`
= help: Use an explicit re-export: `unused as unused`

Safe fix
30 30 | from . import aliased as aliased # Ok: is redundant alias
Expand All @@ -39,4 +39,4 @@ __init__.py:36:26: F401 `.renamed` imported but unused; consider removing, addin
36 | from . import renamed as bees # F401: no fix
| ^^^^ F401
|
= help: Use an explicit re-export: `bees`
= help: Use an explicit re-export: `bees as bees`

0 comments on commit 1798425

Please sign in to comment.