mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:56 +00:00
Add a test for stmt assign breaking in preview mode (#7516)
In preview mode, black will consistently break the right side first. This doesn't work yet, but we'll need the test later.
This commit is contained in:
parent
6dade5b9ab
commit
4ae463d04b
13 changed files with 208 additions and 2 deletions
|
@ -255,12 +255,14 @@ impl fmt::Display for DisplayPyOptions<'_> {
|
|||
line-width = {line_width}
|
||||
indent-width = {indent_width}
|
||||
quote-style = {quote_style:?}
|
||||
magic-trailing-comma = {magic_trailing_comma:?}"#,
|
||||
magic-trailing-comma = {magic_trailing_comma:?}
|
||||
preview = {preview:?}"#,
|
||||
indent_style = self.0.indent_style(),
|
||||
indent_width = self.0.indent_width().value(),
|
||||
line_width = self.0.line_width().value(),
|
||||
quote_style = self.0.quote_style(),
|
||||
magic_trailing_comma = self.0.magic_trailing_comma()
|
||||
magic_trailing_comma = self.0.magic_trailing_comma(),
|
||||
preview = self.0.preview()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,6 +116,7 @@ line-width = 88
|
|||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
@ -229,6 +230,7 @@ line-width = 88
|
|||
indent-width = 2
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
@ -342,6 +344,7 @@ line-width = 88
|
|||
indent-width = 8
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
@ -455,6 +458,7 @@ line-width = 88
|
|||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
|
|
@ -134,6 +134,7 @@ line-width = 88
|
|||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
@ -282,6 +283,7 @@ line-width = 88
|
|||
indent-width = 4
|
||||
quote-style = Single
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
|
|
@ -149,6 +149,7 @@ line-width = 88
|
|||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
@ -321,6 +322,7 @@ line-width = 88
|
|||
indent-width = 4
|
||||
quote-style = Single
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
|
|
@ -33,6 +33,7 @@ line-width = 88
|
|||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
@ -65,6 +66,7 @@ line-width = 88
|
|||
indent-width = 2
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
|
|
@ -14,6 +14,7 @@ line-width = 88
|
|||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
@ -27,6 +28,7 @@ line-width = 88
|
|||
indent-width = 1
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
@ -40,6 +42,7 @@ line-width = 88
|
|||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
|
|
@ -29,6 +29,7 @@ line-width = 88
|
|||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
@ -58,6 +59,7 @@ line-width = 88
|
|||
indent-width = 2
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
@ -87,6 +89,7 @@ line-width = 88
|
|||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
|
|
@ -47,6 +47,7 @@ line-width = 88
|
|||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
@ -99,6 +100,7 @@ line-width = 88
|
|||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Ignore
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/assign_breaking.py
|
||||
---
|
||||
## Input
|
||||
```py
|
||||
# Below is black stable style
|
||||
# In preview style, black always breaks the right side first
|
||||
|
||||
if True:
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
] = cccccccc.ccccccccccccc.cccccccc
|
||||
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
] = cccccccc.ccccccccccccc().cccccccc
|
||||
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
] = cccccccc.ccccccccccccc(d).cccccccc
|
||||
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (
|
||||
cccccccc.ccccccccccccc(d).cccccccc + e
|
||||
)
|
||||
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (
|
||||
cccccccc.ccccccccccccc.cccccccc + e
|
||||
)
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (
|
||||
cccccccc.ccccccccccccc.cccccccc
|
||||
+ eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
||||
)
|
||||
|
||||
self._cache: dict[
|
||||
DependencyCacheKey, list[list[DependencyPackage]]
|
||||
] = collections.defaultdict(list)
|
||||
self._cached_dependencies_by_level: dict[
|
||||
int, list[DependencyCacheKey]
|
||||
] = collections.defaultdict(list)
|
||||
```
|
||||
|
||||
## Outputs
|
||||
### Output 1
|
||||
```
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
# Below is black stable style
|
||||
# In preview style, black always breaks the right side first
|
||||
|
||||
if True:
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
] = cccccccc.ccccccccccccc.cccccccc
|
||||
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
] = cccccccc.ccccccccccccc().cccccccc
|
||||
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
] = cccccccc.ccccccccccccc(d).cccccccc
|
||||
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (
|
||||
cccccccc.ccccccccccccc(d).cccccccc + e
|
||||
)
|
||||
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (
|
||||
cccccccc.ccccccccccccc.cccccccc + e
|
||||
)
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (
|
||||
cccccccc.ccccccccccccc.cccccccc
|
||||
+ eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
||||
)
|
||||
|
||||
self._cache: dict[
|
||||
DependencyCacheKey, list[list[DependencyPackage]]
|
||||
] = collections.defaultdict(list)
|
||||
self._cached_dependencies_by_level: dict[
|
||||
int, list[DependencyCacheKey]
|
||||
] = collections.defaultdict(list)
|
||||
```
|
||||
|
||||
|
||||
### Output 2
|
||||
```
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Enabled
|
||||
```
|
||||
|
||||
```py
|
||||
# Below is black stable style
|
||||
# In preview style, black always breaks the right side first
|
||||
|
||||
if True:
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
] = cccccccc.ccccccccccccc.cccccccc
|
||||
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
] = cccccccc.ccccccccccccc().cccccccc
|
||||
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
] = cccccccc.ccccccccccccc(d).cccccccc
|
||||
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (
|
||||
cccccccc.ccccccccccccc(d).cccccccc + e
|
||||
)
|
||||
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (
|
||||
cccccccc.ccccccccccccc.cccccccc + e
|
||||
)
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (
|
||||
cccccccc.ccccccccccccc.cccccccc
|
||||
+ eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
||||
)
|
||||
|
||||
self._cache: dict[
|
||||
DependencyCacheKey, list[list[DependencyPackage]]
|
||||
] = collections.defaultdict(list)
|
||||
self._cached_dependencies_by_level: dict[
|
||||
int, list[DependencyCacheKey]
|
||||
] = collections.defaultdict(list)
|
||||
```
|
||||
|
||||
|
||||
|
|
@ -22,6 +22,7 @@ line-width = 88
|
|||
indent-width = 2
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
@ -43,6 +44,7 @@ line-width = 88
|
|||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
@ -67,6 +69,7 @@ line-width = 88
|
|||
indent-width = 8
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue