Avoid line break before for in comprehension if outer expression expands (#5912)
This commit is contained in:
@@ -278,16 +278,14 @@ aaaaaaaaaaaaaa + {
|
||||
eeeeeee,
|
||||
}
|
||||
aaaaaaaaaaaaaa + [
|
||||
a
|
||||
for x in bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
a for x in bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
]
|
||||
(
|
||||
aaaaaaaaaaaaaa
|
||||
+ (a for x in bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb)
|
||||
)
|
||||
aaaaaaaaaaaaaa + {
|
||||
a
|
||||
for x in bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
a for x in bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
}
|
||||
|
||||
# Wraps it in parentheses if it needs to break both left and right
|
||||
|
||||
@@ -80,7 +80,19 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression
|
||||
a, # Trailing
|
||||
) in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension # Trailing
|
||||
} # Trailing
|
||||
# Trailing```
|
||||
# Trailing
|
||||
|
||||
|
||||
# Regression tests for https://github.com/astral-sh/ruff/issues/5911
|
||||
selected_choices = {
|
||||
k: str(v) for v in value if str(v) not in self.choices.field.empty_values
|
||||
}
|
||||
|
||||
selected_choices = {
|
||||
k: str(v)
|
||||
for vvvvvvvvvvvvvvvvvvvvvvv in value if str(v) not in self.choices.field.empty_values
|
||||
}
|
||||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
@@ -217,6 +229,18 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression
|
||||
) in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension # Trailing
|
||||
} # Trailing
|
||||
# Trailing
|
||||
|
||||
|
||||
# Regression tests for https://github.com/astral-sh/ruff/issues/5911
|
||||
selected_choices = {
|
||||
k: str(v) for v in value if str(v) not in self.choices.field.empty_values
|
||||
}
|
||||
|
||||
selected_choices = {
|
||||
k: str(v)
|
||||
for vvvvvvvvvvvvvvvvvvvvvvv in value
|
||||
if str(v) not in self.choices.field.empty_values
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -49,6 +49,16 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression
|
||||
if
|
||||
gggggggggggggggggggggggggggggggggggggggggggg
|
||||
]
|
||||
|
||||
# Regression tests for https://github.com/astral-sh/ruff/issues/5911
|
||||
selected_choices = [
|
||||
str(v) for v in value if str(v) not in self.choices.field.empty_values
|
||||
]
|
||||
|
||||
selected_choices = [
|
||||
str(v)
|
||||
for vvvvvvvvvvvvvvvvvvvvvvv in value if str(v) not in self.choices.field.empty_values
|
||||
]
|
||||
```
|
||||
|
||||
## Output
|
||||
@@ -101,6 +111,17 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression
|
||||
< hhhhhhhhhhhhhhhhhhhhhhhhhh
|
||||
if gggggggggggggggggggggggggggggggggggggggggggg
|
||||
]
|
||||
|
||||
# Regression tests for https://github.com/astral-sh/ruff/issues/5911
|
||||
selected_choices = [
|
||||
str(v) for v in value if str(v) not in self.choices.field.empty_values
|
||||
]
|
||||
|
||||
selected_choices = [
|
||||
str(v)
|
||||
for vvvvvvvvvvvvvvvvvvvvvvv in value
|
||||
if str(v) not in self.choices.field.empty_values
|
||||
]
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -49,6 +49,16 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression
|
||||
if
|
||||
gggggggggggggggggggggggggggggggggggggggggggg
|
||||
}
|
||||
|
||||
# Regression tests for https://github.com/astral-sh/ruff/issues/5911
|
||||
selected_choices = {
|
||||
str(v) for v in value if str(v) not in self.choices.field.empty_values
|
||||
}
|
||||
|
||||
selected_choices = {
|
||||
str(v)
|
||||
for vvvvvvvvvvvvvvvvvvvvvvv in value if str(v) not in self.choices.field.empty_values
|
||||
}
|
||||
```
|
||||
|
||||
## Output
|
||||
@@ -101,6 +111,17 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression
|
||||
< hhhhhhhhhhhhhhhhhhhhhhhhhh
|
||||
if gggggggggggggggggggggggggggggggggggggggggggg
|
||||
}
|
||||
|
||||
# Regression tests for https://github.com/astral-sh/ruff/issues/5911
|
||||
selected_choices = {
|
||||
str(v) for v in value if str(v) not in self.choices.field.empty_values
|
||||
}
|
||||
|
||||
selected_choices = {
|
||||
str(v)
|
||||
for vvvvvvvvvvvvvvvvvvvvvvv in value
|
||||
if str(v) not in self.choices.field.empty_values
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user