mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
Fix ranges for global usages (#6917)
## Summary The range of the usage from `Globals` should be the range of the identifier, not the range of the full `global pandas` statement. Closes https://github.com/astral-sh/ruff/issues/6914.
This commit is contained in:
parent
381fc5b2a8
commit
d0b051e447
8 changed files with 77 additions and 30 deletions
|
@ -5,7 +5,7 @@
|
|||
use std::ops::Index;
|
||||
|
||||
use ruff_python_ast as ast;
|
||||
use ruff_python_ast::Stmt;
|
||||
use ruff_python_ast::{Ranged, Stmt};
|
||||
use ruff_text_size::TextRange;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
|
@ -75,9 +75,9 @@ impl<'a> GlobalsVisitor<'a> {
|
|||
impl<'a> StatementVisitor<'a> for GlobalsVisitor<'a> {
|
||||
fn visit_stmt(&mut self, stmt: &'a Stmt) {
|
||||
match stmt {
|
||||
Stmt::Global(ast::StmtGlobal { names, range }) => {
|
||||
Stmt::Global(ast::StmtGlobal { names, range: _ }) => {
|
||||
for name in names {
|
||||
self.0.insert(name.as_str(), *range);
|
||||
self.0.insert(name.as_str(), name.range());
|
||||
}
|
||||
}
|
||||
Stmt::FunctionDef(_) | Stmt::ClassDef(_) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue