-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing file with rule F401 cause infinite loop #12570
Comments
Cool bug, thanks! |
This is an issue with NFKC normalization. If you apply this diff to Ruff: diff --git a/crates/ruff_linter/src/fix/codemods.rs b/crates/ruff_linter/src/fix/codemods.rs
index c3c769172..ed4061435 100644
--- a/crates/ruff_linter/src/fix/codemods.rs
+++ b/crates/ruff_linter/src/fix/codemods.rs
@@ -80,7 +80,7 @@ pub(crate) fn remove_imports<'a>(
for member in member_names {
let alias_index = aliases
.iter()
- .position(|alias| member == qualified_name_from_name_or_attribute(&alias.name));
+ .position(|alias| dbg!(member) == dbg!(qualified_name_from_name_or_attribute(&alias.name)));
if let Some(index) = alias_index {
aliases.remove(index);
}
diff --git a/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs b/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs
index bfa884801..4c86744db 100644
--- a/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs
+++ b/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs
@@ -397,6 +397,8 @@ pub(crate) fn unused_import(checker: &Checker, scope: &Scope, diagnostics: &mut
}
diagnostics.push(diagnostic);
}
+
+ panic!()
} Then the output from the debug calls is as follows:
And I'll also paste a screenshot because it looks like GitHub might actually normalize these confusables as well when it renders them in an issue comment?!): If you look very closely at that screenshot, you can see that the
|
ruff 0.5.5+353 (2f54d05 2024-07-29)
file content(at the bottom should be attached raw, not formatted file - github removes some non-printable characters, so copying from here may not work):
error
Ruff build, that was used to reproduce problem(compiled on Ubuntu 22.04 with release mode + debug symbols + debug assertions + overflow checks) - https://github.com/qarmin/Automated-Fuzzer/releases/download/Nightly/ruff.7z
python_compressed.zip
The text was updated successfully, but these errors were encountered: