Skip to content

Commit

Permalink
Use function range for reimplemented-operator diagnostics (#11271)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed May 3, 2024
1 parent 894cd13 commit 8dd3811
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use anyhow::Result;

use ruff_diagnostics::{Diagnostic, Edit, Fix, FixAvailability, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::identifier::Identifier;
use ruff_python_ast::{self as ast, Expr, ExprSlice, ExprSubscript, ExprTuple, Parameters, Stmt};
use ruff_python_semantic::SemanticModel;
use ruff_source_file::Locator;
Expand Down Expand Up @@ -118,7 +119,7 @@ impl Ranged for FunctionLike<'_> {
fn range(&self) -> TextRange {
match self {
Self::Lambda(expr) => expr.range(),
Self::Function(stmt) => stmt.range(),
Self::Function(stmt) => stmt.identifier(),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,18 +778,18 @@ FURB118.py:33:17: FURB118 [*] Use `operator.itemgetter(slice(None))` instead of
35 36 |
36 37 | def op_not2(x):

FURB118.py:36:1: FURB118 Use `operator.not_` instead of defining a function
FURB118.py:36:5: FURB118 Use `operator.not_` instead of defining a function
|
36 | / def op_not2(x):
37 | | return not x
| |________________^ FURB118
36 | def op_not2(x):
| ^^^^^^^ FURB118
37 | return not x
|
= help: Replace with `operator.not_`

FURB118.py:40:1: FURB118 Use `operator.add` instead of defining a function
FURB118.py:40:5: FURB118 Use `operator.add` instead of defining a function
|
40 | / def op_add2(x, y):
41 | | return x + y
| |________________^ FURB118
40 | def op_add2(x, y):
| ^^^^^^^ FURB118
41 | return x + y
|
= help: Replace with `operator.add`

0 comments on commit 8dd3811

Please sign in to comment.