accept snapshots

This commit is contained in:
Brent Westbrook 2025-10-20 15:11:43 -04:00
parent c1ba13e3e9
commit 1d61766826
6 changed files with 285 additions and 101 deletions

View File

@ -81,89 +81,17 @@ dict_with_really_long_names = {
```diff
--- Black
+++ Ruff
@@ -1,20 +1,14 @@
@@ -46,7 +46,9 @@
[
a
- for graph_path_expression in (
- refined_constraint.condition_as_predicate.variables
- )
+ for graph_path_expression in refined_constraint.condition_as_predicate.variables
]
[
a
- for graph_path_expression in (
- refined_constraint.condition_as_predicate.variables
- )
+ for graph_path_expression in refined_constraint.condition_as_predicate.variables
]
[
a
- for graph_path_expression in (
- refined_constraint.condition_as_predicate.variables
- )
+ for graph_path_expression in refined_constraint.condition_as_predicate.variables
]
[
a
@@ -25,9 +19,7 @@
[
(foobar_very_long_key, foobar_very_long_value)
- for foobar_very_long_key, foobar_very_long_value in (
- foobar_very_long_dictionary.items()
- )
+ for foobar_very_long_key, foobar_very_long_value in foobar_very_long_dictionary.items()
]
# Don't split the `in` if it's not too long
@@ -47,9 +39,7 @@
[
x
for x in bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
- for y in (
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- )
+ for y in xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
]
]
@@ -58,31 +48,23 @@
graph_path_expression
for refined_constraint in self._local_constraint_refinements.values()
if refined_constraint is not None
- for graph_path_expression in (
- refined_constraint.condition_as_predicate.variables
- )
+ for graph_path_expression in refined_constraint.condition_as_predicate.variables
]
# Dictionary comprehensions
dict_with_really_long_names = {
really_really_long_key_name: an_even_longer_really_really_long_key_value
- for really_really_long_key_name, an_even_longer_really_really_long_key_value in (
- really_really_really_long_dict_name.items()
- )
+ for really_really_long_key_name, an_even_longer_really_really_long_key_value in really_really_really_long_dict_name.items()
}
{
key_with_super_really_long_name: key_with_super_really_long_name
- for key_with_super_really_long_name in (
- dictionary_with_super_really_long_name
- )
+ for key_with_super_really_long_name in dictionary_with_super_really_long_name
}
{
key_with_super_really_long_name: key_with_super_really_long_name
- for key_with_super_really_long_name in (
- dictionary_with_super_really_long_name
- )
+ for key_with_super_really_long_name in dictionary_with_super_really_long_name
}
{
key_with_super_really_long_name: key_with_super_really_long_name
- for key in dictionary
+ for key in (dictionary)
}
- for x in bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+ for x in (
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+ )
for y in (
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
)
```
## Ruff Output
@ -171,15 +99,21 @@ dict_with_really_long_names = {
```python
[
a
for graph_path_expression in refined_constraint.condition_as_predicate.variables
for graph_path_expression in (
refined_constraint.condition_as_predicate.variables
)
]
[
a
for graph_path_expression in refined_constraint.condition_as_predicate.variables
for graph_path_expression in (
refined_constraint.condition_as_predicate.variables
)
]
[
a
for graph_path_expression in refined_constraint.condition_as_predicate.variables
for graph_path_expression in (
refined_constraint.condition_as_predicate.variables
)
]
[
a
@ -190,7 +124,9 @@ dict_with_really_long_names = {
[
(foobar_very_long_key, foobar_very_long_value)
for foobar_very_long_key, foobar_very_long_value in foobar_very_long_dictionary.items()
for foobar_very_long_key, foobar_very_long_value in (
foobar_very_long_dictionary.items()
)
]
# Don't split the `in` if it's not too long
@ -209,8 +145,12 @@ expected = [i for i in (a if b else c)]
[
[
x
for x in bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
for y in xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
for x in (
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
)
for y in (
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
)
]
]
@ -219,25 +159,33 @@ graph_path_expressions_in_local_constraint_refinements = [
graph_path_expression
for refined_constraint in self._local_constraint_refinements.values()
if refined_constraint is not None
for graph_path_expression in refined_constraint.condition_as_predicate.variables
for graph_path_expression in (
refined_constraint.condition_as_predicate.variables
)
]
# Dictionary comprehensions
dict_with_really_long_names = {
really_really_long_key_name: an_even_longer_really_really_long_key_value
for really_really_long_key_name, an_even_longer_really_really_long_key_value in really_really_really_long_dict_name.items()
for really_really_long_key_name, an_even_longer_really_really_long_key_value in (
really_really_really_long_dict_name.items()
)
}
{
key_with_super_really_long_name: key_with_super_really_long_name
for key_with_super_really_long_name in dictionary_with_super_really_long_name
for key_with_super_really_long_name in (
dictionary_with_super_really_long_name
)
}
{
key_with_super_really_long_name: key_with_super_really_long_name
for key_with_super_really_long_name in dictionary_with_super_really_long_name
for key_with_super_really_long_name in (
dictionary_with_super_really_long_name
)
}
{
key_with_super_really_long_name: key_with_super_really_long_name
for key in (dictionary)
for key in dictionary
}
```

View File

@ -689,6 +689,17 @@ def length_rst_in_section():
```diff
--- Stable
+++ Preview
@@ -255,8 +255,8 @@
... def by_first_letter_of_column_values(self, col: str) -> list[pl.DataFrame]:
... return [
... self._df.filter(pl.col(col).str.starts_with(c))
- ... for c in sorted(
- ... set(df.select(pl.col(col).str.slice(0, 1)).to_series())
+ ... for c in (
+ ... sorted(set(df.select(pl.col(col).str.slice(0, 1)).to_series()))
... )
... ]
"""
@@ -270,9 +270,11 @@
Examples
@ -1806,6 +1817,17 @@ def length_rst_in_section():
```diff
--- Stable
+++ Preview
@@ -255,8 +255,8 @@
... def by_first_letter_of_column_values(self, col: str) -> list[pl.DataFrame]:
... return [
... self._df.filter(pl.col(col).str.starts_with(c))
- ... for c in sorted(
- ... set(df.select(pl.col(col).str.slice(0, 1)).to_series())
+ ... for c in (
+ ... sorted(set(df.select(pl.col(col).str.slice(0, 1)).to_series()))
... )
... ]
"""
@@ -270,9 +270,11 @@
Examples
@ -2914,7 +2936,28 @@ def length_rst_in_section():
```diff
--- Stable
+++ Preview
@@ -700,9 +700,11 @@
@@ -681,11 +681,15 @@
... ) -> list[pl.DataFrame]:
... return [
... self._df.filter(pl.col(col).str.starts_with(c))
- ... for c in sorted(
- ... set(
- ... df.select(
- ... pl.col(col).str.slice(0, 1)
- ... ).to_series()
+ ... for c in (
+ ... sorted(
+ ... set(
+ ... df.select(
+ ... pl.col(
+ ... col
+ ... ).str.slice(0, 1)
+ ... ).to_series()
+ ... )
... )
... )
... ]
@@ -700,9 +704,11 @@
Examples
--------
@ -2929,7 +2972,7 @@ def length_rst_in_section():
"""
@@ -730,30 +732,28 @@
@@ -730,30 +736,28 @@
Integer length of the list of numbers.
Example:
@ -2982,7 +3025,7 @@ def length_rst_in_section():
20
"""
@@ -768,30 +768,28 @@
@@ -768,30 +772,28 @@
Integer length of the list of numbers.
Example:
@ -3035,7 +3078,7 @@ def length_rst_in_section():
20
"""
@@ -809,31 +807,29 @@
@@ -809,31 +811,29 @@
Example:
```
@ -3090,7 +3133,7 @@ def length_rst_in_section():
```
"""
@@ -843,31 +839,29 @@
@@ -843,31 +843,29 @@
"""
Do cool stuff::
@ -3145,7 +3188,7 @@ def length_rst_in_section():
"""
pass
@@ -878,29 +872,27 @@
@@ -878,29 +876,27 @@
Examples:
Do cool stuff::

View File

@ -1,7 +1,6 @@
---
source: crates/ruff_python_formatter/tests/fixtures.rs
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/dict_comp.py
snapshot_kind: text
---
## Input
```python
@ -404,3 +403,68 @@ query = {
for key, queries in self._filters.items()
}
```
## Preview changes
```diff
--- Stable
+++ Preview
@@ -20,9 +20,10 @@
# above c
c # c
# above in
- in # in
- # above e
- e # e
+ in ( # in
+ # above e
+ e # e
+ )
# above if
if # if
# above f
@@ -43,7 +44,9 @@
for ccccccccccccccccccccccccccccccccccccccc, ddddddddddddddddddd, [
eeeeeeeeeeeeeeeeeeeeee,
fffffffffffffffffffffffff,
- ] in eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffggggggggggggggggggggghhhhhhhhhhhhhhothermoreeand_even_moreddddddddddddddddddddd
+ ] in (
+ eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffggggggggggggggggggggghhhhhhhhhhhhhhothermoreeand_even_moreddddddddddddddddddddd
+ )
if fffffffffffffffffffffffffffffffffffffffffff
< gggggggggggggggggggggggggggggggggggggggggggggg
< hhhhhhhhhhhhhhhhhhhhhhhhhh
@@ -74,7 +77,9 @@
a,
a,
a,
- ] in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension
+ ] in (
+ this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension
+ )
}
{
k: v
@@ -99,7 +104,9 @@
a,
a,
a,
- ) in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension
+ ) in (
+ this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension
+ )
}
# Leading
@@ -126,7 +133,9 @@
a,
a,
a, # Trailing
- ) in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension # Trailing
+ ) in (
+ this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension
+ ) # Trailing
} # Trailing
# Trailing
```

View File

@ -1,7 +1,6 @@
---
source: crates/ruff_python_formatter/tests/fixtures.rs
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/generator_exp.py
snapshot_kind: text
---
## Input
```python
@ -160,3 +159,23 @@ tuple(
)
)
```
## Preview changes
```diff
--- Stable
+++ Preview
@@ -11,10 +11,10 @@
f((1 for _ in a))
# make sure source parenthesis detection isn't fooled by these
-f((1) for _ in (a))
+f((1) for _ in a)
# combination of the two above
-f(((1) for _ in (a)))
+f(((1) for _ in a))
bases = tuple(
(base._meta.label_lower if hasattr(base, "_meta") else base)
```

View File

@ -1,7 +1,6 @@
---
source: crates/ruff_python_formatter/tests/fixtures.rs
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/list_comp.py
snapshot_kind: text
---
## Input
```python
@ -379,3 +378,83 @@ y = [
x
]
```
## Preview changes
```diff
--- Stable
+++ Preview
@@ -20,9 +20,10 @@
# above c
c # c
# above in
- in # in
- # above e
- e # e
+ in ( # in
+ # above e
+ e # e
+ )
# above if
if # if
# above f
@@ -40,7 +41,9 @@
for ccccccccccccccccccccccccccccccccccccccc, ddddddddddddddddddd, [
eeeeeeeeeeeeeeeeeeeeee,
fffffffffffffffffffffffff,
- ] in eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffggggggggggggggggggggghhhhhhhhhhhhhhothermoreeand_even_moreddddddddddddddddddddd
+ ] in (
+ eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffggggggggggggggggggggghhhhhhhhhhhhhhothermoreeand_even_moreddddddddddddddddddddd
+ )
if fffffffffffffffffffffffffffffffffffffffffff
< gggggggggggggggggggggggggggggggggggggggggggggg
< hhhhhhhhhhhhhhhhhhhhhhhhhh
@@ -112,9 +115,11 @@
[
f(x, y)
- for head_name in f(
- x,
- y,
+ for head_name in (
+ f(
+ x,
+ y,
+ )
)
if head_name
]
@@ -130,13 +135,15 @@
[
1
- for components in b # pylint: disable=undefined-loop-variable # integer 1 may only have decimal 01-09
- + c # negative decimal
+ for components in ( # pylint: disable=undefined-loop-variable
+ b # integer 1 may only have decimal 01-09
+ + c
+ ) # negative decimal
]
# Parenthesized targets and iterators.
[x for (x) in y]
-[x for x in (y)]
+[x for x in y]
# Leading expression comments:
@@ -186,9 +193,10 @@
a
for
# comment
- a in
- # comment
- x
+ a in (
+ # comment
+ x
+ )
if
# asdasd
"askldaklsdnmklasmdlkasmdlkasmdlkasmdasd" != "as,mdnaskldmlkasdmlaksdmlkasdlkasdm"
```

View File

@ -1,7 +1,6 @@
---
source: crates/ruff_python_formatter/tests/fixtures.rs
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/set_comp.py
snapshot_kind: text
---
## Input
```python
@ -124,3 +123,35 @@ selected_choices = {
if str(v) not in self.choices.field.empty_values
}
```
## Preview changes
```diff
--- Stable
+++ Preview
@@ -20,9 +20,10 @@
# above c
c # c
# above in
- in # in
- # above e
- e # e
+ in ( # in
+ # above e
+ e # e
+ )
# above if
if # if
# above f
@@ -40,7 +41,9 @@
for ccccccccccccccccccccccccccccccccccccccc, ddddddddddddddddddd, [
eeeeeeeeeeeeeeeeeeeeee,
fffffffffffffffffffffffff,
- ] in eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffggggggggggggggggggggghhhhhhhhhhhhhhothermoreeand_even_moreddddddddddddddddddddd
+ ] in (
+ eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffggggggggggggggggggggghhhhhhhhhhhhhhothermoreeand_even_moreddddddddddddddddddddd
+ )
if fffffffffffffffffffffffffffffffffffffffffff
< gggggggggggggggggggggggggggggggggggggggggggggg
< hhhhhhhhhhhhhhhhhhhhhhhhhh
```