mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-15 08:00:46 +00:00
Remove Comprehension priority (#6947)
This commit is contained in:
parent
adb48692d6
commit
715d86dae9
3 changed files with 29 additions and 7 deletions
|
@ -434,16 +434,17 @@ impl<'input> CanOmitOptionalParenthesesVisitor<'input> {
|
|||
// Visits a subexpression, ignoring whether it is parenthesized or not
|
||||
fn visit_subexpression(&mut self, expr: &'input Expr) {
|
||||
match expr {
|
||||
Expr::Dict(_) | Expr::List(_) | Expr::Tuple(_) | Expr::Set(_) => {
|
||||
Expr::Dict(_)
|
||||
| Expr::List(_)
|
||||
| Expr::Tuple(_)
|
||||
| Expr::Set(_)
|
||||
| Expr::ListComp(_)
|
||||
| Expr::SetComp(_)
|
||||
| Expr::DictComp(_) => {
|
||||
self.any_parenthesized_expressions = true;
|
||||
// The values are always parenthesized, don't visit.
|
||||
return;
|
||||
}
|
||||
Expr::ListComp(_) | Expr::SetComp(_) | Expr::DictComp(_) => {
|
||||
self.any_parenthesized_expressions = true;
|
||||
self.update_max_priority(OperatorPriority::Comprehension);
|
||||
return;
|
||||
}
|
||||
// It's impossible for a file smaller or equal to 4GB to contain more than 2^32 comparisons
|
||||
// because each comparison requires a left operand, and `n` `operands` and right sides.
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
|
@ -789,7 +790,6 @@ enum OperatorPriority {
|
|||
String,
|
||||
BooleanOperation,
|
||||
Conditional,
|
||||
Comprehension,
|
||||
}
|
||||
|
||||
impl From<ast::Operator> for OperatorPriority {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue