Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use function range for reimplemented-operator diagnostics #11271

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`
Loading