From 84ab21f073ff9ba76379f4a8373474095488b748 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 8 Jan 2024 19:29:20 -0500 Subject: [PATCH] Add a fix for `redefinition-while-unused` (#9419) ## Summary This PR enables Ruff to remove redefined imports, as in: ```python import os import os print(os) ``` Previously, Ruff would flag `F811` on the second `import os`, but couldn't fix it. For now, this fix is marked as safe, but only available in preview. Closes https://github.com/astral-sh/ruff/issues/3477. --- .../checkers/ast/analyze/deferred_scopes.rs | 29 +++++++++++++++-- crates/ruff_linter/src/rules/pyflakes/mod.rs | 28 ++++++++++++++++ .../pyflakes/rules/redefined_while_unused.rs | 9 +++++- ...ules__pyflakes__tests__F811_F811_0.py.snap | 1 + ...ules__pyflakes__tests__F811_F811_1.py.snap | 1 + ...les__pyflakes__tests__F811_F811_12.py.snap | 1 + ...les__pyflakes__tests__F811_F811_15.py.snap | 1 + ...les__pyflakes__tests__F811_F811_16.py.snap | 1 + ...les__pyflakes__tests__F811_F811_17.py.snap | 2 ++ ...ules__pyflakes__tests__F811_F811_2.py.snap | 1 + ...les__pyflakes__tests__F811_F811_21.py.snap | 1 + ...les__pyflakes__tests__F811_F811_23.py.snap | 1 + ...les__pyflakes__tests__F811_F811_26.py.snap | 1 + ...ules__pyflakes__tests__F811_F811_3.py.snap | 1 + ...ules__pyflakes__tests__F811_F811_4.py.snap | 1 + ...ules__pyflakes__tests__F811_F811_5.py.snap | 1 + ...ules__pyflakes__tests__F811_F811_6.py.snap | 1 + ...ules__pyflakes__tests__F811_F811_8.py.snap | 1 + ...shadowed_global_import_in_local_scope.snap | 1 + ...shadowed_import_shadow_in_local_scope.snap | 1 + ..._shadowed_local_import_in_local_scope.snap | 1 + ...lakes__tests__preview__F811_F811_0.py.snap | 12 +++++++ ...lakes__tests__preview__F811_F811_1.py.snap | 15 +++++++++ ...akes__tests__preview__F811_F811_10.py.snap | 4 +++ ...akes__tests__preview__F811_F811_11.py.snap | 4 +++ ...akes__tests__preview__F811_F811_12.py.snap | 22 +++++++++++++ ...akes__tests__preview__F811_F811_13.py.snap | 4 +++ ...akes__tests__preview__F811_F811_14.py.snap | 4 +++ ...akes__tests__preview__F811_F811_15.py.snap | 12 +++++++ ...akes__tests__preview__F811_F811_16.py.snap | 14 ++++++++ ...akes__tests__preview__F811_F811_17.py.snap | 32 +++++++++++++++++++ ...akes__tests__preview__F811_F811_18.py.snap | 4 +++ ...akes__tests__preview__F811_F811_19.py.snap | 4 +++ ...lakes__tests__preview__F811_F811_2.py.snap | 15 +++++++++ ...akes__tests__preview__F811_F811_20.py.snap | 4 +++ ...akes__tests__preview__F811_F811_21.py.snap | 25 +++++++++++++++ ...akes__tests__preview__F811_F811_22.py.snap | 4 +++ ...akes__tests__preview__F811_F811_23.py.snap | 18 +++++++++++ ...akes__tests__preview__F811_F811_24.py.snap | 4 +++ ...akes__tests__preview__F811_F811_25.py.snap | 4 +++ ...akes__tests__preview__F811_F811_26.py.snap | 14 ++++++++ ...akes__tests__preview__F811_F811_27.py.snap | 4 +++ ...lakes__tests__preview__F811_F811_3.py.snap | 11 +++++++ ...lakes__tests__preview__F811_F811_4.py.snap | 11 +++++++ ...lakes__tests__preview__F811_F811_5.py.snap | 11 +++++++ ...lakes__tests__preview__F811_F811_6.py.snap | 21 ++++++++++++ ...lakes__tests__preview__F811_F811_7.py.snap | 4 +++ ...lakes__tests__preview__F811_F811_8.py.snap | 24 ++++++++++++++ ...lakes__tests__preview__F811_F811_9.py.snap | 4 +++ 49 files changed, 391 insertions(+), 3 deletions(-) create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_0.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_1.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_10.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_11.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_12.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_13.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_14.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_15.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_16.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_17.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_18.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_19.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_2.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_20.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_21.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_22.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_23.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_24.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_25.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_26.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_27.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_3.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_4.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_5.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_6.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_7.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_8.py.snap create mode 100644 crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_9.py.snap diff --git a/crates/ruff_linter/src/checkers/ast/analyze/deferred_scopes.rs b/crates/ruff_linter/src/checkers/ast/analyze/deferred_scopes.rs index 14bc02c0df76c..e6c46334dd7af 100644 --- a/crates/ruff_linter/src/checkers/ast/analyze/deferred_scopes.rs +++ b/crates/ruff_linter/src/checkers/ast/analyze/deferred_scopes.rs @@ -1,10 +1,11 @@ -use ruff_diagnostics::Diagnostic; +use ruff_diagnostics::{Diagnostic, Fix}; use ruff_python_semantic::analyze::visibility; -use ruff_python_semantic::{Binding, BindingKind, ScopeKind}; +use ruff_python_semantic::{Binding, BindingKind, Imported, ScopeKind}; use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::codes::Rule; +use crate::fix; use crate::rules::{ flake8_pyi, flake8_type_checking, flake8_unused_arguments, pyflakes, pylint, ruff, }; @@ -247,9 +248,33 @@ pub(crate) fn deferred_scopes(checker: &mut Checker) { }, binding.range(), ); + if let Some(range) = binding.parent_range(&checker.semantic) { diagnostic.set_parent(range.start()); } + + if checker.settings.preview.is_enabled() { + if let Some(import) = binding.as_any_import() { + if let Some(source) = binding.source { + diagnostic.try_set_fix(|| { + let statement = checker.semantic().statement(source); + let parent = checker.semantic().parent_statement(source); + let edit = fix::edits::remove_unused_imports( + std::iter::once(import.member_name().as_ref()), + statement, + parent, + checker.locator(), + checker.stylist(), + checker.indexer(), + )?; + Ok(Fix::safe_edit(edit).isolate(Checker::isolation( + checker.semantic().parent_statement_id(source), + ))) + }); + } + } + } + diagnostics.push(diagnostic); } } diff --git a/crates/ruff_linter/src/rules/pyflakes/mod.rs b/crates/ruff_linter/src/rules/pyflakes/mod.rs index 6f9ad095718bb..1645fb8ec9e12 100644 --- a/crates/ruff_linter/src/rules/pyflakes/mod.rs +++ b/crates/ruff_linter/src/rules/pyflakes/mod.rs @@ -168,6 +168,34 @@ mod tests { Ok(()) } + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_0.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_1.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_10.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_11.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_12.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_13.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_14.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_15.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_16.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_17.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_18.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_19.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_2.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_20.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_21.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_22.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_23.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_24.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_25.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_26.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_27.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_3.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_4.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_5.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_6.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_7.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_8.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_9.py"))] #[test_case(Rule::UnusedVariable, Path::new("F841_4.py"))] fn preview_rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!( diff --git a/crates/ruff_linter/src/rules/pyflakes/rules/redefined_while_unused.rs b/crates/ruff_linter/src/rules/pyflakes/rules/redefined_while_unused.rs index 6beceb6addb45..f65090d328b6d 100644 --- a/crates/ruff_linter/src/rules/pyflakes/rules/redefined_while_unused.rs +++ b/crates/ruff_linter/src/rules/pyflakes/rules/redefined_while_unused.rs @@ -1,4 +1,4 @@ -use ruff_diagnostics::Violation; +use ruff_diagnostics::{FixAvailability, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_source_file::SourceRow; @@ -29,9 +29,16 @@ pub struct RedefinedWhileUnused { } impl Violation for RedefinedWhileUnused { + const FIX_AVAILABILITY: FixAvailability = FixAvailability::Sometimes; + #[derive_message_formats] fn message(&self) -> String { let RedefinedWhileUnused { name, row } = self; format!("Redefinition of unused `{name}` from {row}") } + + fn fix_title(&self) -> Option { + let RedefinedWhileUnused { name, .. } = self; + Some(format!("Remove definition: `{name}`")) + } } diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_0.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_0.py.snap index 1b8ba23d083eb..009ba794b77b6 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_0.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_0.py.snap @@ -7,5 +7,6 @@ F811_0.py:10:5: F811 Redefinition of unused `bar` from line 6 | ^^^ F811 11 | pass | + = help: Remove definition: `bar` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_1.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_1.py.snap index 196fcfd1c321c..3c5023ea35e37 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_1.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_1.py.snap @@ -6,5 +6,6 @@ F811_1.py:1:25: F811 Redefinition of unused `FU` from line 1 1 | import fu as FU, bar as FU | ^^ F811 | + = help: Remove definition: `FU` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_12.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_12.py.snap index 3582a992fd0ac..ccc34ca245585 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_12.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_12.py.snap @@ -9,5 +9,6 @@ F811_12.py:6:20: F811 Redefinition of unused `mixer` from line 2 | ^^^^^ F811 7 | mixer(123) | + = help: Remove definition: `mixer` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_15.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_15.py.snap index ee9654382c523..7f9b7cca18fee 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_15.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_15.py.snap @@ -7,5 +7,6 @@ F811_15.py:4:5: F811 Redefinition of unused `fu` from line 1 | ^^ F811 5 | pass | + = help: Remove definition: `fu` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_16.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_16.py.snap index 7a9b81e5e7b67..ace7efc109b4e 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_16.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_16.py.snap @@ -9,5 +9,6 @@ F811_16.py:8:13: F811 Redefinition of unused `fu` from line 3 | ^^ F811 9 | pass | + = help: Remove definition: `fu` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_17.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_17.py.snap index ebcb6d42a2c9a..d6a499c088e44 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_17.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_17.py.snap @@ -9,6 +9,7 @@ F811_17.py:6:12: F811 Redefinition of unused `fu` from line 2 7 | 8 | def baz(): | + = help: Remove definition: `fu` F811_17.py:9:13: F811 Redefinition of unused `fu` from line 6 | @@ -17,5 +18,6 @@ F811_17.py:9:13: F811 Redefinition of unused `fu` from line 6 | ^^ F811 10 | pass | + = help: Remove definition: `fu` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_2.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_2.py.snap index c51c3fe03fe93..78c4a39f1cbed 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_2.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_2.py.snap @@ -6,5 +6,6 @@ F811_2.py:1:34: F811 Redefinition of unused `FU` from line 1 1 | from moo import fu as FU, bar as FU | ^^ F811 | + = help: Remove definition: `FU` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_21.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_21.py.snap index 2cf8492603c53..48525af0fd19a 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_21.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_21.py.snap @@ -9,5 +9,6 @@ F811_21.py:32:5: F811 Redefinition of unused `Sequence` from line 26 | ^^^^^^^^ F811 33 | ) | + = help: Remove definition: `Sequence` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_23.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_23.py.snap index 4816ae23e805c..b4996ebf10b34 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_23.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_23.py.snap @@ -7,5 +7,6 @@ F811_23.py:4:15: F811 Redefinition of unused `foo` from line 3 4 | import bar as foo | ^^^ F811 | + = help: Remove definition: `foo` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_26.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_26.py.snap index 142ee127fd6cf..a51c892a97937 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_26.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_26.py.snap @@ -9,5 +9,6 @@ F811_26.py:5:9: F811 Redefinition of unused `func` from line 2 | ^^^^ F811 6 | pass | + = help: Remove definition: `func` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_3.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_3.py.snap index 81d8e6bb5b976..7e749b088747a 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_3.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_3.py.snap @@ -6,5 +6,6 @@ F811_3.py:1:12: F811 Redefinition of unused `fu` from line 1 1 | import fu; fu = 3 | ^^ F811 | + = help: Remove definition: `fu` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_4.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_4.py.snap index 0877d0f556a55..0c7c2a4523d79 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_4.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_4.py.snap @@ -6,5 +6,6 @@ F811_4.py:1:12: F811 Redefinition of unused `fu` from line 1 1 | import fu; fu, bar = 3 | ^^ F811 | + = help: Remove definition: `fu` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_5.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_5.py.snap index e6217fbe58fe1..b21d2c3508948 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_5.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_5.py.snap @@ -6,5 +6,6 @@ F811_5.py:1:13: F811 Redefinition of unused `fu` from line 1 1 | import fu; [fu, bar] = 3 | ^^ F811 | + = help: Remove definition: `fu` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_6.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_6.py.snap index afb110adb0327..a246b2275d0b5 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_6.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_6.py.snap @@ -9,5 +9,6 @@ F811_6.py:6:12: F811 Redefinition of unused `os` from line 5 | ^^ F811 7 | os.path | + = help: Remove definition: `os` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_8.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_8.py.snap index 9680f0457382a..86799a2aaf7cc 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_8.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_8.py.snap @@ -10,5 +10,6 @@ F811_8.py:5:12: F811 Redefinition of unused `os` from line 4 6 | except: 7 | pass | + = help: Remove definition: `os` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap index 85e1d7d06fed0..844c9a7cba6ff 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap @@ -25,5 +25,6 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs 6 | 7 | # Despite this `del`, `import os` in `f` should still be flagged as shadowing an unused | + = help: Remove definition: `os` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap index 8a7530cecd872..9dfb6527c7f9b 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap @@ -24,5 +24,6 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs | ^^ F811 6 | print(os) | + = help: Remove definition: `os` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap index b8807e970a98a..97a806998dc7f 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap @@ -10,5 +10,6 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs 5 | 6 | # Despite this `del`, `import os` should still be flagged as shadowing an unused | + = help: Remove definition: `os` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_0.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_0.py.snap new file mode 100644 index 0000000000000..009ba794b77b6 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_0.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_0.py:10:5: F811 Redefinition of unused `bar` from line 6 + | +10 | def bar(): + | ^^^ F811 +11 | pass + | + = help: Remove definition: `bar` + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_1.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_1.py.snap new file mode 100644 index 0000000000000..b3d2ebd453667 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_1.py.snap @@ -0,0 +1,15 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_1.py:1:25: F811 [*] Redefinition of unused `FU` from line 1 + | +1 | import fu as FU, bar as FU + | ^^ F811 + | + = help: Remove definition: `FU` + +ℹ Safe fix +1 |-import fu as FU, bar as FU + 1 |+import fu as FU + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_10.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_10.py.snap new file mode 100644 index 0000000000000..d0b409f39ee0b --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_10.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_11.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_11.py.snap new file mode 100644 index 0000000000000..d0b409f39ee0b --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_11.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_12.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_12.py.snap new file mode 100644 index 0000000000000..1411fddf047c7 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_12.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_12.py:6:20: F811 [*] Redefinition of unused `mixer` from line 2 + | +4 | pass +5 | else: +6 | from bb import mixer + | ^^^^^ F811 +7 | mixer(123) + | + = help: Remove definition: `mixer` + +ℹ Safe fix +3 3 | except ImportError: +4 4 | pass +5 5 | else: +6 |- from bb import mixer + 6 |+ pass +7 7 | mixer(123) + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_13.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_13.py.snap new file mode 100644 index 0000000000000..d0b409f39ee0b --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_13.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_14.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_14.py.snap new file mode 100644 index 0000000000000..d0b409f39ee0b --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_14.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_15.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_15.py.snap new file mode 100644 index 0000000000000..7f9b7cca18fee --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_15.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_15.py:4:5: F811 Redefinition of unused `fu` from line 1 + | +4 | def fu(): + | ^^ F811 +5 | pass + | + = help: Remove definition: `fu` + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_16.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_16.py.snap new file mode 100644 index 0000000000000..ace7efc109b4e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_16.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_16.py:8:13: F811 Redefinition of unused `fu` from line 3 + | +6 | def bar(): +7 | def baz(): +8 | def fu(): + | ^^ F811 +9 | pass + | + = help: Remove definition: `fu` + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_17.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_17.py.snap new file mode 100644 index 0000000000000..b2e62e8597fb6 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_17.py.snap @@ -0,0 +1,32 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_17.py:6:12: F811 [*] Redefinition of unused `fu` from line 2 + | +5 | def bar(): +6 | import fu + | ^^ F811 +7 | +8 | def baz(): + | + = help: Remove definition: `fu` + +ℹ Safe fix +3 3 | +4 4 | +5 5 | def bar(): +6 |- import fu +7 6 | +8 7 | def baz(): +9 8 | def fu(): + +F811_17.py:9:13: F811 Redefinition of unused `fu` from line 6 + | + 8 | def baz(): + 9 | def fu(): + | ^^ F811 +10 | pass + | + = help: Remove definition: `fu` + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_18.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_18.py.snap new file mode 100644 index 0000000000000..d0b409f39ee0b --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_18.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_19.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_19.py.snap new file mode 100644 index 0000000000000..d0b409f39ee0b --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_19.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_2.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_2.py.snap new file mode 100644 index 0000000000000..9e87d29c8d81e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_2.py.snap @@ -0,0 +1,15 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_2.py:1:34: F811 [*] Redefinition of unused `FU` from line 1 + | +1 | from moo import fu as FU, bar as FU + | ^^ F811 + | + = help: Remove definition: `FU` + +ℹ Safe fix +1 |-from moo import fu as FU, bar as FU + 1 |+from moo import fu as FU + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_20.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_20.py.snap new file mode 100644 index 0000000000000..d0b409f39ee0b --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_20.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_21.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_21.py.snap new file mode 100644 index 0000000000000..6d0405c66f566 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_21.py.snap @@ -0,0 +1,25 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_21.py:32:5: F811 [*] Redefinition of unused `Sequence` from line 26 + | +30 | from typing import ( +31 | List, # noqa: F811 +32 | Sequence, + | ^^^^^^^^ F811 +33 | ) + | + = help: Remove definition: `Sequence` + +ℹ Safe fix +29 29 | # This should ignore the first error. +30 30 | from typing import ( +31 31 | List, # noqa: F811 +32 |- Sequence, +33 |-) + 32 |+ ) +34 33 | +35 34 | # This should ignore both errors. +36 35 | from typing import ( # noqa + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_22.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_22.py.snap new file mode 100644 index 0000000000000..d0b409f39ee0b --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_22.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_23.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_23.py.snap new file mode 100644 index 0000000000000..d03de5d32f98b --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_23.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_23.py:4:15: F811 [*] Redefinition of unused `foo` from line 3 + | +3 | import foo as foo +4 | import bar as foo + | ^^^ F811 + | + = help: Remove definition: `foo` + +ℹ Safe fix +1 1 | """Test that shadowing an explicit re-export produces a warning.""" +2 2 | +3 3 | import foo as foo +4 |-import bar as foo + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_24.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_24.py.snap new file mode 100644 index 0000000000000..d0b409f39ee0b --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_24.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_25.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_25.py.snap new file mode 100644 index 0000000000000..d0b409f39ee0b --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_25.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_26.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_26.py.snap new file mode 100644 index 0000000000000..a51c892a97937 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_26.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_26.py:5:9: F811 Redefinition of unused `func` from line 2 + | +3 | pass +4 | +5 | def func(self): + | ^^^^ F811 +6 | pass + | + = help: Remove definition: `func` + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_27.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_27.py.snap new file mode 100644 index 0000000000000..d0b409f39ee0b --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_27.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_3.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_3.py.snap new file mode 100644 index 0000000000000..7e749b088747a --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_3.py.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_3.py:1:12: F811 Redefinition of unused `fu` from line 1 + | +1 | import fu; fu = 3 + | ^^ F811 + | + = help: Remove definition: `fu` + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_4.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_4.py.snap new file mode 100644 index 0000000000000..0c7c2a4523d79 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_4.py.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_4.py:1:12: F811 Redefinition of unused `fu` from line 1 + | +1 | import fu; fu, bar = 3 + | ^^ F811 + | + = help: Remove definition: `fu` + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_5.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_5.py.snap new file mode 100644 index 0000000000000..b21d2c3508948 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_5.py.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_5.py:1:13: F811 Redefinition of unused `fu` from line 1 + | +1 | import fu; [fu, bar] = 3 + | ^^ F811 + | + = help: Remove definition: `fu` + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_6.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_6.py.snap new file mode 100644 index 0000000000000..92fc67263100e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_6.py.snap @@ -0,0 +1,21 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_6.py:6:12: F811 [*] Redefinition of unused `os` from line 5 + | +4 | if i == 1: +5 | import os +6 | import os + | ^^ F811 +7 | os.path + | + = help: Remove definition: `os` + +ℹ Safe fix +3 3 | i = 2 +4 4 | if i == 1: +5 5 | import os +6 |- import os +7 6 | os.path + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_7.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_7.py.snap new file mode 100644 index 0000000000000..d0b409f39ee0b --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_7.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_8.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_8.py.snap new file mode 100644 index 0000000000000..07e8aeb1e6324 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_8.py.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_8.py:5:12: F811 [*] Redefinition of unused `os` from line 4 + | +3 | try: +4 | import os +5 | import os + | ^^ F811 +6 | except: +7 | pass + | + = help: Remove definition: `os` + +ℹ Safe fix +2 2 | +3 3 | try: +4 4 | import os +5 |- import os +6 5 | except: +7 6 | pass +8 7 | os.path + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_9.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_9.py.snap new file mode 100644 index 0000000000000..d0b409f39ee0b --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F811_F811_9.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +