Add parenthesized flag to ExprTuple and ExprGenerator (#9614)

This commit is contained in:
Micha Reiser 2024-02-26 16:35:20 +01:00 committed by GitHub
parent ab4bd71755
commit 77c5561646
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
65 changed files with 391 additions and 139 deletions

View file

@ -12,7 +12,6 @@ use ruff_source_file::Locator;
use ruff_text_size::{Ranged, TextLen, TextRange, TextSize};
use crate::comments::visitor::{CommentPlacement, DecoratedComment};
use crate::expression::expr_generator_exp::is_generator_parenthesized;
use crate::expression::expr_slice::{assign_comment_in_slice, ExprSliceCommentSection};
use crate::other::parameters::{
assign_argument_separator_comment_placement, find_parameter_separators,
@ -315,12 +314,11 @@ fn handle_enclosed_comment<'a>(
| AnyNodeRef::ExprSet(_)
| AnyNodeRef::ExprListComp(_)
| AnyNodeRef::ExprSetComp(_) => handle_bracketed_end_of_line_comment(comment, locator),
AnyNodeRef::ExprTuple(tuple) if tuple.is_parenthesized(locator.contents()) => {
handle_bracketed_end_of_line_comment(comment, locator)
}
AnyNodeRef::ExprGeneratorExp(generator)
if is_generator_parenthesized(generator, locator.contents()) =>
{
AnyNodeRef::ExprTuple(ast::ExprTuple {
parenthesized: true,
..
}) => handle_bracketed_end_of_line_comment(comment, locator),
AnyNodeRef::ExprGeneratorExp(generator) if generator.parenthesized => {
handle_bracketed_end_of_line_comment(comment, locator)
}
_ => CommentPlacement::Default(comment),