mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-21 19:05:09 +00:00
Cover Black's is_aritmetic_like
formatting (#5738)
This commit is contained in:
parent
513de13c46
commit
8187bf9f7e
14 changed files with 159 additions and 96 deletions
|
@ -84,3 +84,13 @@ pub(crate) enum NodeLevel {
|
|||
/// Formatting nodes that are enclosed by a parenthesized (any `[]`, `{}` or `()`) expression.
|
||||
ParenthesizedExpression,
|
||||
}
|
||||
|
||||
impl NodeLevel {
|
||||
/// Returns `true` if the expression is in a parenthesized context.
|
||||
pub(crate) const fn is_parenthesized(self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
NodeLevel::Expression(Some(_)) | NodeLevel::ParenthesizedExpression
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue