mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-10 21:58:05 +00:00
Fix instability with await fluent style (#8676)
Fix an instability where await was followed by a breaking fluent style expression: ```python test_data = await ( Stream.from_async(async_data) .flat_map_async() .map() .filter_async(is_valid_data) .to_list() ) ``` Note that this technically a minor style change (see ecosystem check)
This commit is contained in:
parent
841e6c889e
commit
dca430f4d2
5 changed files with 42 additions and 4 deletions
|
@ -20,7 +20,7 @@ impl FormatNodeRule<ExprAwait> for FormatExprAwait {
|
|||
[
|
||||
token("await"),
|
||||
space(),
|
||||
maybe_parenthesize_expression(value, item, Parenthesize::IfRequired)
|
||||
maybe_parenthesize_expression(value, item, Parenthesize::IfBreaks)
|
||||
]
|
||||
)
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ use crate::comments::{
|
|||
use crate::context::{NodeLevel, WithNodeLevel};
|
||||
use crate::prelude::*;
|
||||
|
||||
/// From the perspective of the expression, under which circumstances does it need parentheses
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub(crate) enum OptionalParentheses {
|
||||
/// Add parentheses if the expression expands over multiple lines
|
||||
|
@ -41,7 +42,8 @@ pub(crate) trait NeedsParentheses {
|
|||
) -> OptionalParentheses;
|
||||
}
|
||||
|
||||
/// Configures if the expression should be parenthesized.
|
||||
/// From the perspective of the parent statement or expression, when should the child expression
|
||||
/// get parentheses?
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub(crate) enum Parenthesize {
|
||||
/// Parenthesizes the expression if it doesn't fit on a line OR if the expression is parenthesized in the source code.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue