From 4e9e58bdc00a3d050d17d668700efdcf4a017bdb Mon Sep 17 00:00:00 2001 From: Harutaka Kawamura Date: Sat, 31 Dec 2022 21:41:53 +0900 Subject: [PATCH] Improve `T20X` ranges (#1502) --- src/checkers/ast.rs | 2 +- src/flake8_print/plugins/print_call.rs | 6 +++--- .../ruff__flake8_print__tests__T201_T201.py.snap | 8 ++++---- .../ruff__flake8_print__tests__T203_T203.py.snap | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/checkers/ast.rs b/src/checkers/ast.rs index 5caf083727..6fbef0c565 100644 --- a/src/checkers/ast.rs +++ b/src/checkers/ast.rs @@ -1708,7 +1708,7 @@ where if self.settings.enabled.contains(&CheckCode::T201) || self.settings.enabled.contains(&CheckCode::T203) { - flake8_print::plugins::print_call(self, expr, func, keywords); + flake8_print::plugins::print_call(self, func, keywords); } // flake8-bugbear diff --git a/src/flake8_print/plugins/print_call.rs b/src/flake8_print/plugins/print_call.rs index 3521fa9b6f..2c7ec45a61 100644 --- a/src/flake8_print/plugins/print_call.rs +++ b/src/flake8_print/plugins/print_call.rs @@ -8,7 +8,7 @@ use crate::checkers::ast::Checker; use crate::checks::{Check, CheckKind}; /// T201, T203 -pub fn print_call(checker: &mut Checker, expr: &Expr, func: &Expr, keywords: &[Keyword]) { +pub fn print_call(checker: &mut Checker, func: &Expr, keywords: &[Keyword]) { let mut check = { let call_path = dealias_call_path(collect_call_paths(func), &checker.import_aliases); if match_call_path(&call_path, "", "print", &checker.from_imports) { @@ -27,9 +27,9 @@ pub fn print_call(checker: &mut Checker, expr: &Expr, func: &Expr, keywords: &[K } } } - Check::new(CheckKind::PrintFound, Range::from_located(expr)) + Check::new(CheckKind::PrintFound, Range::from_located(func)) } else if match_call_path(&call_path, "pprint", "pprint", &checker.from_imports) { - Check::new(CheckKind::PPrintFound, Range::from_located(expr)) + Check::new(CheckKind::PPrintFound, Range::from_located(func)) } else { return; } diff --git a/src/flake8_print/snapshots/ruff__flake8_print__tests__T201_T201.py.snap b/src/flake8_print/snapshots/ruff__flake8_print__tests__T201_T201.py.snap index 568f9eb65a..934b904593 100644 --- a/src/flake8_print/snapshots/ruff__flake8_print__tests__T201_T201.py.snap +++ b/src/flake8_print/snapshots/ruff__flake8_print__tests__T201_T201.py.snap @@ -8,7 +8,7 @@ expression: checks column: 0 end_location: row: 4 - column: 22 + column: 5 fix: content: "" location: @@ -24,7 +24,7 @@ expression: checks column: 0 end_location: row: 5 - column: 33 + column: 5 fix: content: "" location: @@ -40,7 +40,7 @@ expression: checks column: 0 end_location: row: 6 - column: 39 + column: 5 fix: content: "" location: @@ -56,7 +56,7 @@ expression: checks column: 0 end_location: row: 7 - column: 39 + column: 5 fix: content: "" location: diff --git a/src/flake8_print/snapshots/ruff__flake8_print__tests__T203_T203.py.snap b/src/flake8_print/snapshots/ruff__flake8_print__tests__T203_T203.py.snap index d2f3e70f6d..a897c14d84 100644 --- a/src/flake8_print/snapshots/ruff__flake8_print__tests__T203_T203.py.snap +++ b/src/flake8_print/snapshots/ruff__flake8_print__tests__T203_T203.py.snap @@ -8,7 +8,7 @@ expression: checks column: 0 end_location: row: 3 - column: 23 + column: 6 fix: content: "" location: @@ -24,7 +24,7 @@ expression: checks column: 0 end_location: row: 7 - column: 30 + column: 13 fix: content: "" location: