From dde97562cf843300cf96bb78fa88c68989769502 Mon Sep 17 00:00:00 2001 From: PLR <51248199+plredmond@users.noreply.github.com> Date: Tue, 14 May 2024 13:53:17 -0700 Subject: [PATCH] Revert "remove the qualified-name field from UnusedImport in favor of the binding-name field (named as .name); update fixture test results" This reverts commit 0696df52aa86fb73496ddaf05e0d675895f4d8c8. --- .../src/rules/pyflakes/rules/unused_import.rs | 23 ++++++++++++++----- ...ules__pyflakes__tests__F401_F401_0.py.snap | 10 ++++---- ...les__pyflakes__tests__F401_F401_11.py.snap | 6 +++-- ...les__pyflakes__tests__F401_F401_15.py.snap | 6 +++-- ...les__pyflakes__tests__F401_F401_17.py.snap | 10 ++++---- ...les__pyflakes__tests__F401_F401_23.py.snap | 4 ++-- ...ules__pyflakes__tests__F401_F401_5.py.snap | 14 ++++++----- ...ules__pyflakes__tests__F401_F401_6.py.snap | 14 ++++++----- ...ules__pyflakes__tests__F401_F401_7.py.snap | 10 ++++---- ...ules__pyflakes__tests__F401_F401_9.py.snap | 6 +++-- ...__pyflakes__tests__future_annotations.snap | 6 +++-- ...s__preview__F401_F401_24____init__.py.snap | 4 ++-- ...01_F401_25__all_nonempty____init__.py.snap | 4 ++-- ..._F401_F401_26__all_empty____init__.py.snap | 4 ++-- ...01_F401_27__all_mistyped____init__.py.snap | 4 ++-- ...01_F401_28__all_multiple____init__.py.snap | 4 ++-- ...F401_29__all_conditional____init__.py.snap | 4 ++-- ..._linter__rules__ruff__tests__ruf100_1.snap | 10 ++++---- 18 files changed, 87 insertions(+), 56 deletions(-) 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 e838cd3905e45..6fe44cf88a578 100644 --- a/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs +++ b/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs @@ -85,8 +85,10 @@ enum UnusedImportContext { /// - [Typing documentation: interface conventions](https://typing.readthedocs.io/en/latest/source/libraries.html#library-interface-public-and-private-symbols) #[violation] pub struct UnusedImport { - /// Name of the import binding + /// Qualified name of the import name: String, + /// Name of the import binding + binding: String, context: Option, multiple: bool, } @@ -113,17 +115,24 @@ impl Violation for UnusedImport { } fn fix_title(&self) -> Option { - let UnusedImport { name, multiple, .. } = self; + let UnusedImport { + name, + binding, + multiple, + .. + } = self; match self.context { Some(UnusedImportContext::Init { first_party: true, dunder_all_count: 1, - }) => Some(format!("Add unused import `{name}` to __all__")), + }) => Some(format!("Add unused import `{binding}` to __all__")), Some(UnusedImportContext::Init { first_party: true, dunder_all_count: 0, - }) => Some(format!("Use an explicit re-export: `{name} as {name}`")), + }) => Some(format!( + "Use an explicit re-export: `{binding} as {binding}`" + )), _ => Some(if *multiple { "Remove unused import".to_string() @@ -310,7 +319,8 @@ pub(crate) fn unused_import(checker: &Checker, scope: &Scope, diagnostics: &mut ) { let mut diagnostic = Diagnostic::new( UnusedImport { - name: binding.name.to_string(), + name: binding.import.qualified_name().to_string(), + binding: binding.name.to_string(), context, multiple, }, @@ -333,7 +343,8 @@ pub(crate) fn unused_import(checker: &Checker, scope: &Scope, diagnostics: &mut for binding in ignored.into_values().flatten() { let mut diagnostic = Diagnostic::new( UnusedImport { - name: binding.name.to_string(), + name: binding.import.qualified_name().to_string(), + binding: binding.name.to_string(), context: None, multiple: false, }, diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_0.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_0.py.snap index e4868ec3d8507..433865de23481 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_0.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_0.py.snap @@ -19,7 +19,7 @@ F401_0.py:2:8: F401 [*] `functools` imported but unused 4 4 | from collections import ( 5 5 | Counter, -F401_0.py:6:5: F401 [*] `OrderedDict` imported but unused +F401_0.py:6:5: F401 [*] `collections.OrderedDict` imported but unused | 4 | from collections import ( 5 | Counter, @@ -28,7 +28,7 @@ F401_0.py:6:5: F401 [*] `OrderedDict` imported but unused 7 | namedtuple, 8 | ) | - = help: Remove unused import: `OrderedDict` + = help: Remove unused import: `collections.OrderedDict` ℹ Safe fix 3 3 | from datetime import datetime @@ -268,13 +268,13 @@ F401_0.py:114:16: F401 [*] `b2` imported but unused 116 115 | 117 116 | # Regression test for: https://github.com/astral-sh/ruff/issues/7244 -F401_0.py:122:1: F401 [*] `noqa` imported but unused +F401_0.py:122:1: F401 [*] `datameta_client_lib.model_helpers.noqa` imported but unused | 121 | from datameta_client_lib.model_helpers import ( 122 | noqa ) | ^^^^ F401 | - = help: Remove unused import: `noqa` + = help: Remove unused import: `datameta_client_lib.model_helpers.noqa` ℹ Safe fix 118 118 | from datameta_client_lib.model_utils import ( # noqa: F401 @@ -282,3 +282,5 @@ F401_0.py:122:1: F401 [*] `noqa` imported but unused 120 120 | 121 |-from datameta_client_lib.model_helpers import ( 122 |-noqa ) + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_11.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_11.py.snap index e78cd69387f0f..39c9b95a011e2 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_11.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_11.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F401_11.py:4:27: F401 [*] `PurePath` imported but unused +F401_11.py:4:27: F401 [*] `pathlib.PurePath` imported but unused | 3 | from typing import List 4 | from pathlib import Path, PurePath | ^^^^^^^^ F401 | - = help: Remove unused import: `PurePath` + = help: Remove unused import: `pathlib.PurePath` ℹ Safe fix 1 1 | """Test: parsing of nested string annotations.""" @@ -18,3 +18,5 @@ F401_11.py:4:27: F401 [*] `PurePath` imported but unused 5 5 | 6 6 | 7 7 | x: """List['Path']""" = [] + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_15.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_15.py.snap index 6dc0c75faf6fb..cd5526e8f4fde 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_15.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_15.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F401_15.py:5:25: F401 [*] `Path` imported but unused +F401_15.py:5:25: F401 [*] `pathlib.Path` imported but unused | 4 | if TYPE_CHECKING: 5 | from pathlib import Path | ^^^^ F401 | - = help: Remove unused import: `Path` + = help: Remove unused import: `pathlib.Path` ℹ Safe fix 2 2 | from django.db.models import ForeignKey @@ -18,3 +18,5 @@ F401_15.py:5:25: F401 [*] `Path` imported but unused 6 6 | 7 7 | 8 8 | class Foo: + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_17.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_17.py.snap index a83b7f71a4c3d..caf5d2c6767c3 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_17.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_17.py.snap @@ -1,7 +1,7 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F401_17.py:12:27: F401 [*] `Thread` imported but unused +F401_17.py:12:27: F401 [*] `threading.Thread` imported but unused | 11 | def fn(thread: Thread): 12 | from threading import Thread @@ -9,7 +9,7 @@ F401_17.py:12:27: F401 [*] `Thread` imported but unused 13 | 14 | # The `Thread` on the left-hand side should resolve to the `Thread` imported at the | - = help: Remove unused import: `Thread` + = help: Remove unused import: `threading.Thread` ℹ Safe fix 9 9 | @@ -20,7 +20,7 @@ F401_17.py:12:27: F401 [*] `Thread` imported but unused 14 13 | # The `Thread` on the left-hand side should resolve to the `Thread` imported at the 15 14 | # top level. -F401_17.py:20:27: F401 [*] `Thread` imported but unused +F401_17.py:20:27: F401 [*] `threading.Thread` imported but unused | 19 | def fn(thread: Thread): 20 | from threading import Thread @@ -28,7 +28,7 @@ F401_17.py:20:27: F401 [*] `Thread` imported but unused 21 | 22 | # The `Thread` on the left-hand side should resolve to the `Thread` imported at the | - = help: Remove unused import: `Thread` + = help: Remove unused import: `threading.Thread` ℹ Safe fix 17 17 | @@ -38,3 +38,5 @@ F401_17.py:20:27: F401 [*] `Thread` imported but unused 21 20 | 22 21 | # The `Thread` on the left-hand side should resolve to the `Thread` imported at the 23 22 | # top level. + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_23.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_23.py.snap index fa0fce1874e39..afde9e550a87d 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_23.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_23.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F401_23.py:4:16: F401 [*] `RegexFlag` imported but unused +F401_23.py:4:16: F401 [*] `re.RegexFlag` imported but unused | 3 | from pathlib import Path 4 | from re import RegexFlag | ^^^^^^^^^ F401 5 | from typing import Annotated | - = help: Remove unused import: `RegexFlag` + = help: Remove unused import: `re.RegexFlag` ℹ Safe fix 1 1 | """Test: ensure that we treat strings in `typing.Annotation` as type definitions.""" diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_5.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_5.py.snap index c987c0dc971fa..e4317c5d195e7 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_5.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_5.py.snap @@ -1,7 +1,7 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F401_5.py:2:17: F401 [*] `c` imported but unused +F401_5.py:2:17: F401 [*] `a.b.c` imported but unused | 1 | """Test: removal of multi-segment and aliases imports.""" 2 | from a.b import c @@ -9,7 +9,7 @@ F401_5.py:2:17: F401 [*] `c` imported but unused 3 | from d.e import f as g 4 | import h.i | - = help: Remove unused import: `c` + = help: Remove unused import: `a.b.c` ℹ Safe fix 1 1 | """Test: removal of multi-segment and aliases imports.""" @@ -18,7 +18,7 @@ F401_5.py:2:17: F401 [*] `c` imported but unused 4 3 | import h.i 5 4 | import j.k as l -F401_5.py:3:22: F401 [*] `g` imported but unused +F401_5.py:3:22: F401 [*] `d.e.f` imported but unused | 1 | """Test: removal of multi-segment and aliases imports.""" 2 | from a.b import c @@ -27,7 +27,7 @@ F401_5.py:3:22: F401 [*] `g` imported but unused 4 | import h.i 5 | import j.k as l | - = help: Remove unused import: `g` + = help: Remove unused import: `d.e.f` ℹ Safe fix 1 1 | """Test: removal of multi-segment and aliases imports.""" @@ -53,17 +53,19 @@ F401_5.py:4:8: F401 [*] `h.i` imported but unused 4 |-import h.i 5 4 | import j.k as l -F401_5.py:5:15: F401 [*] `l` imported but unused +F401_5.py:5:15: F401 [*] `j.k` imported but unused | 3 | from d.e import f as g 4 | import h.i 5 | import j.k as l | ^ F401 | - = help: Remove unused import: `l` + = help: Remove unused import: `j.k` ℹ Safe fix 2 2 | from a.b import c 3 3 | from d.e import f as g 4 4 | import h.i 5 |-import j.k as l + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_6.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_6.py.snap index 094f7d25d79c1..d0db5ee40d5df 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_6.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_6.py.snap @@ -1,7 +1,7 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F401_6.py:7:25: F401 [*] `BackgroundTasks` imported but unused +F401_6.py:7:25: F401 [*] `.background.BackgroundTasks` imported but unused | 6 | # F401 `background.BackgroundTasks` imported but unused 7 | from .background import BackgroundTasks @@ -9,7 +9,7 @@ F401_6.py:7:25: F401 [*] `BackgroundTasks` imported but unused 8 | 9 | # F401 `datastructures.UploadFile` imported but unused | - = help: Remove unused import: `BackgroundTasks` + = help: Remove unused import: `.background.BackgroundTasks` ℹ Safe fix 4 4 | from .applications import FastAPI as FastAPI @@ -20,7 +20,7 @@ F401_6.py:7:25: F401 [*] `BackgroundTasks` imported but unused 9 8 | # F401 `datastructures.UploadFile` imported but unused 10 9 | from .datastructures import UploadFile as FileUpload -F401_6.py:10:43: F401 [*] `FileUpload` imported but unused +F401_6.py:10:43: F401 [*] `.datastructures.UploadFile` imported but unused | 9 | # F401 `datastructures.UploadFile` imported but unused 10 | from .datastructures import UploadFile as FileUpload @@ -28,7 +28,7 @@ F401_6.py:10:43: F401 [*] `FileUpload` imported but unused 11 | 12 | # OK | - = help: Remove unused import: `FileUpload` + = help: Remove unused import: `.datastructures.UploadFile` ℹ Safe fix 7 7 | from .background import BackgroundTasks @@ -58,16 +58,18 @@ F401_6.py:16:8: F401 [*] `background` imported but unused 18 17 | # F401 `datastructures` imported but unused 19 18 | import datastructures as structures -F401_6.py:19:26: F401 [*] `structures` imported but unused +F401_6.py:19:26: F401 [*] `datastructures` imported but unused | 18 | # F401 `datastructures` imported but unused 19 | import datastructures as structures | ^^^^^^^^^^ F401 | - = help: Remove unused import: `structures` + = help: Remove unused import: `datastructures` ℹ Safe fix 16 16 | import background 17 17 | 18 18 | # F401 `datastructures` imported but unused 19 |-import datastructures as structures + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_7.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_7.py.snap index 7c6792b3ef5a8..cb4ec75028592 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_7.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_7.py.snap @@ -1,7 +1,7 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F401_7.py:30:5: F401 [*] `Union` imported but unused +F401_7.py:30:5: F401 [*] `typing.Union` imported but unused | 28 | from typing import ( 29 | Mapping, # noqa: F401 @@ -9,7 +9,7 @@ F401_7.py:30:5: F401 [*] `Union` imported but unused | ^^^^^ F401 31 | ) | - = help: Remove unused import: `Union` + = help: Remove unused import: `typing.Union` ℹ Safe fix 27 27 | # This should ignore the first error. @@ -22,7 +22,7 @@ F401_7.py:30:5: F401 [*] `Union` imported but unused 33 32 | # This should ignore both errors. 34 33 | from typing import ( # noqa -F401_7.py:66:20: F401 [*] `Awaitable` imported but unused +F401_7.py:66:20: F401 [*] `typing.Awaitable` imported but unused | 65 | # This should mark F501 as unused. 66 | from typing import Awaitable, AwaitableGenerator # noqa: F501 @@ -36,7 +36,7 @@ F401_7.py:66:20: F401 [*] `Awaitable` imported but unused 65 65 | # This should mark F501 as unused. 66 |-from typing import Awaitable, AwaitableGenerator # noqa: F501 -F401_7.py:66:31: F401 [*] `AwaitableGenerator` imported but unused +F401_7.py:66:31: F401 [*] `typing.AwaitableGenerator` imported but unused | 65 | # This should mark F501 as unused. 66 | from typing import Awaitable, AwaitableGenerator # noqa: F501 @@ -49,3 +49,5 @@ F401_7.py:66:31: F401 [*] `AwaitableGenerator` imported but unused 64 64 | 65 65 | # This should mark F501 as unused. 66 |-from typing import Awaitable, AwaitableGenerator # noqa: F501 + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_9.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_9.py.snap index f761517e7a0a9..c7071cc24fbfa 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_9.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_9.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F401_9.py:4:22: F401 [*] `baz` imported but unused +F401_9.py:4:22: F401 [*] `foo.baz` imported but unused | 3 | __all__ = ("bar",) 4 | from foo import bar, baz | ^^^ F401 | - = help: Remove unused import: `baz` + = help: Remove unused import: `foo.baz` ℹ Safe fix 1 1 | """Test: late-binding of `__all__`.""" @@ -15,3 +15,5 @@ F401_9.py:4:22: F401 [*] `baz` imported but unused 3 3 | __all__ = ("bar",) 4 |-from foo import bar, baz 4 |+from foo import bar + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__future_annotations.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__future_annotations.snap index b00296aff5532..5a15b089872bd 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__future_annotations.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__future_annotations.snap @@ -1,7 +1,7 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -future_annotations.py:8:5: F401 [*] `Nut` imported but unused +future_annotations.py:8:5: F401 [*] `models.Nut` imported but unused | 6 | from models import ( 7 | Fruit, @@ -9,7 +9,7 @@ future_annotations.py:8:5: F401 [*] `Nut` imported but unused | ^^^ F401 9 | ) | - = help: Remove unused import: `Nut` + = help: Remove unused import: `models.Nut` ℹ Safe fix 5 5 | @@ -27,3 +27,5 @@ future_annotations.py:26:19: F821 Undefined name `Bar` | ^^^ F821 27 | return cls(x=0, y=0) | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_24____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_24____init__.py.snap index 2d1cec6560069..46850ca6619e6 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_24____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_24____init__.py.snap @@ -17,7 +17,7 @@ __init__.py:19:8: F401 [*] `sys` imported but unused; consider removing, adding 21 20 | 22 21 | # first-party -__init__.py:33:15: F401 [*] `unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +__init__.py:33:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | 33 | from . import unused # F401: change to redundant alias | ^^^^^^ F401 @@ -34,7 +34,7 @@ __init__.py:33:15: F401 [*] `unused` imported but unused; consider removing, add 35 35 | 36 36 | from . import renamed as bees # F401: no fix -__init__.py:36:26: F401 `bees` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +__init__.py:36:26: F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | 36 | from . import renamed as bees # F401: no fix | ^^^^ F401 diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_25__all_nonempty____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_25__all_nonempty____init__.py.snap index 9f5ced4132a02..9d04194da7494 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_25__all_nonempty____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_25__all_nonempty____init__.py.snap @@ -17,7 +17,7 @@ __init__.py:19:8: F401 [*] `sys` imported but unused; consider removing, adding 21 20 | 22 21 | # first-party -__init__.py:36:15: F401 [*] `unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +__init__.py:36:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | 36 | from . import unused # F401: add to __all__ | ^^^^^^ F401 @@ -31,7 +31,7 @@ __init__.py:36:15: F401 [*] `unused` imported but unused; consider removing, add 42 |-__all__ = ["argparse", "exported"] 42 |+__all__ = ["argparse", "exported", "unused"] -__init__.py:39:26: F401 [*] `bees` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +__init__.py:39:26: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | 39 | from . import renamed as bees # F401: add to __all__ | ^^^^ F401 diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_26__all_empty____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_26__all_empty____init__.py.snap index b5fab3893b140..6c393f0fbfce9 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_26__all_empty____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_26__all_empty____init__.py.snap @@ -1,7 +1,7 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -__init__.py:5:15: F401 [*] `unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +__init__.py:5:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | 5 | from . import unused # F401: add to __all__ | ^^^^^^ F401 @@ -15,7 +15,7 @@ __init__.py:5:15: F401 [*] `unused` imported but unused; consider removing, addi 11 |-__all__ = [] 11 |+__all__ = ["unused"] -__init__.py:8:26: F401 [*] `bees` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +__init__.py:8:26: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | 8 | from . import renamed as bees # F401: add to __all__ | ^^^^ F401 diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_27__all_mistyped____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_27__all_mistyped____init__.py.snap index f04b42cd9a1f0..c665795df9447 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_27__all_mistyped____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_27__all_mistyped____init__.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -__init__.py:5:15: F401 `unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +__init__.py:5:15: F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | 5 | from . import unused # F401: recommend add to all w/o fix | ^^^^^^ F401 | = help: Add unused import `unused` to __all__ -__init__.py:8:26: F401 `bees` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +__init__.py:8:26: F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | 8 | from . import renamed as bees # F401: recommend add to all w/o fix | ^^^^ F401 diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_28__all_multiple____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_28__all_multiple____init__.py.snap index 5a3f18a41dfc9..a77b95641d619 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_28__all_multiple____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_28__all_multiple____init__.py.snap @@ -1,7 +1,7 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -__init__.py:5:15: F401 [*] `unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +__init__.py:5:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | 5 | from . import unused, renamed as bees # F401: add to __all__ | ^^^^^^ F401 @@ -15,7 +15,7 @@ __init__.py:5:15: F401 [*] `unused` imported but unused; consider removing, addi 8 |-__all__ = []; 8 |+__all__ = ["bees", "unused"]; -__init__.py:5:34: F401 [*] `bees` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +__init__.py:5:34: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | 5 | from . import unused, renamed as bees # F401: add to __all__ | ^^^^ F401 diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_29__all_conditional____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_29__all_conditional____init__.py.snap index 1b6d523467d5d..0100397db388f 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_29__all_conditional____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_29__all_conditional____init__.py.snap @@ -1,7 +1,7 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -__init__.py:8:15: F401 `unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +__init__.py:8:15: F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | 6 | import sys 7 | @@ -12,7 +12,7 @@ __init__.py:8:15: F401 `unused` imported but unused; consider removing, adding t | = help: Remove unused import -__init__.py:8:44: F401 `bees` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +__init__.py:8:44: F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias | 6 | import sys 7 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_1.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_1.snap index 8c9f695740b46..bd0aaf365a2cf 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_1.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_1.snap @@ -1,7 +1,7 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF100_1.py:37:9: F401 [*] `Union` imported but unused +RUF100_1.py:37:9: F401 [*] `typing.Union` imported but unused | 35 | from typing import ( 36 | Mapping, # noqa: F401 @@ -9,7 +9,7 @@ RUF100_1.py:37:9: F401 [*] `Union` imported but unused | ^^^^^ F401 38 | ) | - = help: Remove unused import: `Union` + = help: Remove unused import: `typing.Union` ℹ Safe fix 34 34 | # This should ignore the first error. @@ -103,7 +103,7 @@ RUF100_1.py:72:27: RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) 74 74 | ) 75 75 | -RUF100_1.py:89:24: F401 [*] `Awaitable` imported but unused +RUF100_1.py:89:24: F401 [*] `typing.Awaitable` imported but unused | 87 | def f(): 88 | # This should mark F501 as unused. @@ -119,7 +119,7 @@ RUF100_1.py:89:24: F401 [*] `Awaitable` imported but unused 89 |- from typing import Awaitable, AwaitableGenerator # noqa: F501 89 |+ pass # noqa: F501 -RUF100_1.py:89:35: F401 [*] `AwaitableGenerator` imported but unused +RUF100_1.py:89:35: F401 [*] `typing.AwaitableGenerator` imported but unused | 87 | def f(): 88 | # This should mark F501 as unused. @@ -150,3 +150,5 @@ RUF100_1.py:89:55: RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) 88 88 | # This should mark F501 as unused. 89 |- from typing import Awaitable, AwaitableGenerator # noqa: F501 89 |+ from typing import Awaitable, AwaitableGenerator + +