mirror of
https://github.com/astral-sh/ruff.git
synced 2025-12-23 09:19:58 +00:00
Add token based parenthesized_ranges implementation (#21738)
Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
e6ddeed386
commit
f4e4229683
6 changed files with 339 additions and 80 deletions
|
|
@ -37,13 +37,11 @@ use itertools::Itertools;
|
|||
use ruff_db::{
|
||||
diagnostic::{Annotation, Diagnostic, Span, SubDiagnostic, SubDiagnosticSeverity},
|
||||
parsed::parsed_module,
|
||||
source::source_text,
|
||||
};
|
||||
use ruff_diagnostics::{Edit, Fix};
|
||||
use ruff_python_ast::name::Name;
|
||||
use ruff_python_ast::parenthesize::parentheses_iterator;
|
||||
use ruff_python_ast::token::parentheses_iterator;
|
||||
use ruff_python_ast::{self as ast, AnyNodeRef, StringFlags};
|
||||
use ruff_python_trivia::CommentRanges;
|
||||
use ruff_text_size::{Ranged, TextRange};
|
||||
use rustc_hash::FxHashSet;
|
||||
use std::fmt::{self, Formatter};
|
||||
|
|
@ -2423,9 +2421,7 @@ pub(super) fn report_invalid_assignment<'db>(
|
|||
// ) # ty: ignore <- or here
|
||||
// ```
|
||||
|
||||
let comment_ranges = CommentRanges::from(context.module().tokens());
|
||||
let source = source_text(context.db(), context.file());
|
||||
parentheses_iterator(value_node.into(), None, &comment_ranges, &source)
|
||||
parentheses_iterator(value_node.into(), None, context.module().tokens())
|
||||
.last()
|
||||
.unwrap_or(value_node.range())
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue