mirror of
https://github.com/astral-sh/ruff
synced 2026-01-22 22:10:48 -05:00
30 lines
939 B
Rust
30 lines
939 B
Rust
use crate::comments::Comments;
|
|
use crate::expression::parentheses::{
|
|
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
|
|
};
|
|
use crate::{AsFormat, FormatNodeRule, PyFormatter};
|
|
use ruff_formatter::prelude::{space, text};
|
|
use ruff_formatter::{write, Buffer, FormatResult};
|
|
use rustpython_parser::ast::ExprAwait;
|
|
|
|
#[derive(Default)]
|
|
pub struct FormatExprAwait;
|
|
|
|
impl FormatNodeRule<ExprAwait> for FormatExprAwait {
|
|
fn fmt_fields(&self, item: &ExprAwait, f: &mut PyFormatter) -> FormatResult<()> {
|
|
let ExprAwait { range: _, value } = item;
|
|
write!(f, [text("await"), space(), value.format()])
|
|
}
|
|
}
|
|
|
|
impl NeedsParentheses for ExprAwait {
|
|
fn needs_parentheses(
|
|
&self,
|
|
parenthesize: Parenthesize,
|
|
source: &str,
|
|
comments: &Comments,
|
|
) -> Parentheses {
|
|
default_expression_needs_parentheses(self.into(), parenthesize, source, comments)
|
|
}
|
|
}
|