From 21cace09731f95fdde6029d23a8071a712819885 Mon Sep 17 00:00:00 2001 From: Harutaka Kawamura Date: Sun, 4 Dec 2022 23:13:47 +0900 Subject: [PATCH] Fix `PLR0402` (#1024) --- src/pylint/plugins.rs | 6 +++--- .../snapshots/ruff__pylint__tests__import_aliasing.py.snap | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pylint/plugins.rs b/src/pylint/plugins.rs index a387556427..0182153aa3 100644 --- a/src/pylint/plugins.rs +++ b/src/pylint/plugins.rs @@ -110,10 +110,10 @@ pub fn property_with_parameters( /// PLR0402 pub fn consider_using_from_import(checker: &mut Checker, alias: &Alias) { if let Some(asname) = &alias.node.asname { - if let Some((_, module)) = alias.node.name.rsplit_once('.') { - if module == asname { + if let Some((module, name)) = alias.node.name.rsplit_once('.') { + if name == asname { checker.add_check(Check::new( - CheckKind::ConsiderUsingFromImport(module.to_string(), asname.to_string()), + CheckKind::ConsiderUsingFromImport(module.to_string(), name.to_string()), Range::from_located(alias), )); } diff --git a/src/pylint/snapshots/ruff__pylint__tests__import_aliasing.py.snap b/src/pylint/snapshots/ruff__pylint__tests__import_aliasing.py.snap index 3d7dc6288b..6c91494eac 100644 --- a/src/pylint/snapshots/ruff__pylint__tests__import_aliasing.py.snap +++ b/src/pylint/snapshots/ruff__pylint__tests__import_aliasing.py.snap @@ -4,7 +4,7 @@ expression: checks --- - kind: ConsiderUsingFromImport: - - path + - os - path location: row: 8 @@ -15,7 +15,7 @@ expression: checks fix: ~ - kind: ConsiderUsingFromImport: - - foobar + - foo.bar - foobar location: row: 10