mirror of
https://github.com/astral-sh/ruff
synced 2026-01-08 15:14:19 -05:00
Introduce IndentWidth (#7301)
This commit is contained in:
@@ -253,11 +253,11 @@ impl fmt::Display for DisplayPyOptions<'_> {
|
||||
f,
|
||||
r#"indent-style = {indent_style}
|
||||
line-width = {line_width}
|
||||
tab-width = {tab_width}
|
||||
indent-width = {indent_width}
|
||||
quote-style = {quote_style:?}
|
||||
magic-trailing-comma = {magic_trailing_comma:?}"#,
|
||||
indent_style = self.0.indent_style(),
|
||||
tab_width = self.0.tab_width().value(),
|
||||
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()
|
||||
|
||||
@@ -111,9 +111,9 @@ class TabbedIndent:
|
||||
## Outputs
|
||||
### Output 1
|
||||
```
|
||||
indent-style = Spaces, size: 4
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
tab-width = 8
|
||||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
@@ -224,9 +224,9 @@ class TabbedIndent:
|
||||
|
||||
### Output 2
|
||||
```
|
||||
indent-style = Spaces, size: 2
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
tab-width = 8
|
||||
indent-width = 2
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
@@ -337,9 +337,9 @@ class TabbedIndent:
|
||||
|
||||
### Output 3
|
||||
```
|
||||
indent-style = Tab
|
||||
indent-style = tab
|
||||
line-width = 88
|
||||
tab-width = 8
|
||||
indent-width = 8
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
@@ -450,9 +450,9 @@ class TabbedIndent:
|
||||
|
||||
### Output 4
|
||||
```
|
||||
indent-style = Tab
|
||||
indent-style = tab
|
||||
line-width = 88
|
||||
tab-width = 4
|
||||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
@@ -556,7 +556,7 @@ class TabbedIndent:
|
||||
"""check for correct tabbed formatting
|
||||
^^^^^^^^^^
|
||||
Normal indented line
|
||||
- autor
|
||||
- autor
|
||||
"""
|
||||
```
|
||||
|
||||
|
||||
@@ -129,9 +129,9 @@ test_particular = [
|
||||
## Outputs
|
||||
### Output 1
|
||||
```
|
||||
indent-style = Spaces, size: 4
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
tab-width = 4
|
||||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
@@ -277,9 +277,9 @@ test_particular = [
|
||||
|
||||
### Output 2
|
||||
```
|
||||
indent-style = Spaces, size: 4
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
tab-width = 4
|
||||
indent-width = 4
|
||||
quote-style = Single
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
|
||||
@@ -141,9 +141,9 @@ x = (b"""aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa""" b"""bbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||
## Outputs
|
||||
### Output 1
|
||||
```
|
||||
indent-style = Spaces, size: 4
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
tab-width = 4
|
||||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
@@ -310,9 +310,9 @@ x = (
|
||||
|
||||
### Output 2
|
||||
```
|
||||
indent-style = Spaces, size: 4
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
tab-width = 4
|
||||
indent-width = 4
|
||||
quote-style = Single
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
|
||||
@@ -28,9 +28,9 @@ def test():
|
||||
## Outputs
|
||||
### Output 1
|
||||
```
|
||||
indent-style = Spaces, size: 4
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
tab-width = 4
|
||||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
@@ -60,9 +60,9 @@ def test():
|
||||
|
||||
### Output 2
|
||||
```
|
||||
indent-style = Spaces, size: 2
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
tab-width = 4
|
||||
indent-width = 2
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
|
||||
@@ -9,9 +9,9 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off
|
||||
## Outputs
|
||||
### Output 1
|
||||
```
|
||||
indent-style = Spaces, size: 4
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
tab-width = 4
|
||||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
@@ -22,9 +22,9 @@ magic-trailing-comma = Respect
|
||||
|
||||
### Output 2
|
||||
```
|
||||
indent-style = Spaces, size: 1
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
tab-width = 4
|
||||
indent-width = 1
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
@@ -35,9 +35,9 @@ magic-trailing-comma = Respect
|
||||
|
||||
### Output 3
|
||||
```
|
||||
indent-style = Tab
|
||||
indent-style = tab
|
||||
line-width = 88
|
||||
tab-width = 4
|
||||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
|
||||
@@ -24,9 +24,9 @@ not_fixed
|
||||
## Outputs
|
||||
### Output 1
|
||||
```
|
||||
indent-style = Spaces, size: 4
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
tab-width = 4
|
||||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
@@ -53,9 +53,9 @@ not_fixed
|
||||
|
||||
### Output 2
|
||||
```
|
||||
indent-style = Spaces, size: 2
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
tab-width = 4
|
||||
indent-width = 2
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
@@ -82,9 +82,9 @@ not_fixed
|
||||
|
||||
### Output 3
|
||||
```
|
||||
indent-style = Tab
|
||||
indent-style = tab
|
||||
line-width = 88
|
||||
tab-width = 4
|
||||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
|
||||
@@ -42,9 +42,9 @@ with (a,): # magic trailing comma
|
||||
## Outputs
|
||||
### Output 1
|
||||
```
|
||||
indent-style = Spaces, size: 4
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
tab-width = 4
|
||||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
@@ -94,9 +94,9 @@ with (
|
||||
|
||||
### Output 2
|
||||
```
|
||||
indent-style = Spaces, size: 4
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
tab-width = 4
|
||||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Ignore
|
||||
```
|
||||
|
||||
@@ -5,45 +5,42 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/tab_width.
|
||||
## Input
|
||||
```py
|
||||
# Fits with tab width 2
|
||||
1 + " 012345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
(1 + " 012345678901234567890123456789012345678901234567890123456789012345678901234567")
|
||||
|
||||
# Fits with tab width 4
|
||||
1 + " 0123456789012345678901234567890123456789012345678901234567890123456789012345678"
|
||||
(1 + " 0123456789012345678901234567890123456789012345678901234567890123456789012345")
|
||||
|
||||
# Fits with tab width 8
|
||||
1 + " 012345678901234567890123456789012345678901234567890123456789012345678901234"
|
||||
(1 + " 012345678901234567890123456789012345678901234567890123456789012345678901")
|
||||
```
|
||||
|
||||
## Outputs
|
||||
### Output 1
|
||||
```
|
||||
indent-style = Spaces, size: 4
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
tab-width = 2
|
||||
indent-width = 2
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
|
||||
```py
|
||||
# Fits with tab width 2
|
||||
(
|
||||
1
|
||||
+ " 012345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
)
|
||||
(1 + " 012345678901234567890123456789012345678901234567890123456789012345678901234567")
|
||||
|
||||
# Fits with tab width 4
|
||||
1 + " 0123456789012345678901234567890123456789012345678901234567890123456789012345678"
|
||||
(1 + " 0123456789012345678901234567890123456789012345678901234567890123456789012345")
|
||||
|
||||
# Fits with tab width 8
|
||||
1 + " 012345678901234567890123456789012345678901234567890123456789012345678901234"
|
||||
(1 + " 012345678901234567890123456789012345678901234567890123456789012345678901")
|
||||
```
|
||||
|
||||
|
||||
### Output 2
|
||||
```
|
||||
indent-style = Spaces, size: 4
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
tab-width = 4
|
||||
indent-width = 4
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
@@ -52,17 +49,41 @@ magic-trailing-comma = Respect
|
||||
# Fits with tab width 2
|
||||
(
|
||||
1
|
||||
+ " 012345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
+ " 012345678901234567890123456789012345678901234567890123456789012345678901234567"
|
||||
)
|
||||
|
||||
# Fits with tab width 4
|
||||
(1 + " 0123456789012345678901234567890123456789012345678901234567890123456789012345")
|
||||
|
||||
# Fits with tab width 8
|
||||
(1 + " 012345678901234567890123456789012345678901234567890123456789012345678901")
|
||||
```
|
||||
|
||||
|
||||
### Output 3
|
||||
```
|
||||
indent-style = space
|
||||
line-width = 88
|
||||
indent-width = 8
|
||||
quote-style = Double
|
||||
magic-trailing-comma = Respect
|
||||
```
|
||||
|
||||
```py
|
||||
# Fits with tab width 2
|
||||
(
|
||||
1
|
||||
+ " 012345678901234567890123456789012345678901234567890123456789012345678901234567"
|
||||
)
|
||||
|
||||
# Fits with tab width 4
|
||||
(
|
||||
1
|
||||
+ " 0123456789012345678901234567890123456789012345678901234567890123456789012345678"
|
||||
1
|
||||
+ " 0123456789012345678901234567890123456789012345678901234567890123456789012345"
|
||||
)
|
||||
|
||||
# Fits with tab width 8
|
||||
1 + " 012345678901234567890123456789012345678901234567890123456789012345678901234"
|
||||
(1 + " 012345678901234567890123456789012345678901234567890123456789012345678901")
|
||||
```
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user