Format ExpressionStarred nodes (#5654)

This commit is contained in:
Micha Reiser 2023-07-11 08:08:08 +02:00 committed by GitHub
parent 9f486fa841
commit 987111f5fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 192 additions and 581 deletions

View file

@ -1,22 +1,32 @@
use rustpython_parser::ast::ExprStarred;
use ruff_formatter::write;
use crate::comments::Comments;
use crate::expression::parentheses::{
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
};
use crate::{not_yet_implemented_custom_text, FormatNodeRule, PyFormatter};
use ruff_formatter::{write, Buffer, FormatResult};
use rustpython_parser::ast::ExprStarred;
use crate::prelude::*;
use crate::FormatNodeRule;
#[derive(Default)]
pub struct FormatExprStarred;
impl FormatNodeRule<ExprStarred> for FormatExprStarred {
fn fmt_fields(&self, _item: &ExprStarred, f: &mut PyFormatter) -> FormatResult<()> {
write!(
f,
[not_yet_implemented_custom_text(
"*NOT_YET_IMPLEMENTED_ExprStarred"
)]
)
fn fmt_fields(&self, item: &ExprStarred, f: &mut PyFormatter) -> FormatResult<()> {
let ExprStarred {
range: _,
value,
ctx: _,
} = item;
write!(f, [text("*"), value.format()])
}
fn fmt_dangling_comments(&self, node: &ExprStarred, f: &mut PyFormatter) -> FormatResult<()> {
debug_assert_eq!(f.context().comments().dangling_comments(node), []);
Ok(())
}
}