mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 02:12:22 +00:00
Apply consistent code block labels (#8563)
This ensures the python label is used for all python code blocks for consistency. ## Test Plan Visual inspection of all changes via git client ensuring no other changes were made in error.
This commit is contained in:
parent
0ea1076f85
commit
4fdf97a95c
151 changed files with 364 additions and 359 deletions
|
@ -1415,7 +1415,7 @@ impl<'a> Checker<'a> {
|
||||||
// subsequent nodes are evaluated in the inner scope.
|
// subsequent nodes are evaluated in the inner scope.
|
||||||
//
|
//
|
||||||
// For example, given:
|
// For example, given:
|
||||||
// ```py
|
// ```python
|
||||||
// class A:
|
// class A:
|
||||||
// T = range(10)
|
// T = range(10)
|
||||||
//
|
//
|
||||||
|
@ -1423,7 +1423,7 @@ impl<'a> Checker<'a> {
|
||||||
// ```
|
// ```
|
||||||
//
|
//
|
||||||
// Conceptually, this is compiled as:
|
// Conceptually, this is compiled as:
|
||||||
// ```py
|
// ```python
|
||||||
// class A:
|
// class A:
|
||||||
// T = range(10)
|
// T = range(10)
|
||||||
//
|
//
|
||||||
|
|
|
@ -189,7 +189,7 @@ impl<'a> Insertion<'a> {
|
||||||
Tok::NonLogicalNewline => {}
|
Tok::NonLogicalNewline => {}
|
||||||
Tok::Indent => {
|
Tok::Indent => {
|
||||||
// This is like:
|
// This is like:
|
||||||
// ```py
|
// ```python
|
||||||
// if True:
|
// if True:
|
||||||
// pass
|
// pass
|
||||||
// ```
|
// ```
|
||||||
|
|
|
@ -209,7 +209,7 @@ impl<'a> Importer<'a> {
|
||||||
// We also add a no-op edit to force conflicts with any other fixes that might try to
|
// We also add a no-op edit to force conflicts with any other fixes that might try to
|
||||||
// remove the import. Consider:
|
// remove the import. Consider:
|
||||||
//
|
//
|
||||||
// ```py
|
// ```python
|
||||||
// import sys
|
// import sys
|
||||||
//
|
//
|
||||||
// quit()
|
// quit()
|
||||||
|
|
|
@ -71,7 +71,7 @@ fn black_compatibility() {
|
||||||
// today.
|
// today.
|
||||||
let mut snapshot = String::new();
|
let mut snapshot = String::new();
|
||||||
write!(snapshot, "{}", Header::new("Input")).unwrap();
|
write!(snapshot, "{}", Header::new("Input")).unwrap();
|
||||||
write!(snapshot, "{}", CodeFrame::new("py", &content)).unwrap();
|
write!(snapshot, "{}", CodeFrame::new("python", &content)).unwrap();
|
||||||
|
|
||||||
write!(snapshot, "{}", Header::new("Black Differences")).unwrap();
|
write!(snapshot, "{}", Header::new("Black Differences")).unwrap();
|
||||||
|
|
||||||
|
@ -83,10 +83,10 @@ fn black_compatibility() {
|
||||||
write!(snapshot, "{}", CodeFrame::new("diff", &diff)).unwrap();
|
write!(snapshot, "{}", CodeFrame::new("diff", &diff)).unwrap();
|
||||||
|
|
||||||
write!(snapshot, "{}", Header::new("Ruff Output")).unwrap();
|
write!(snapshot, "{}", Header::new("Ruff Output")).unwrap();
|
||||||
write!(snapshot, "{}", CodeFrame::new("py", &formatted_code)).unwrap();
|
write!(snapshot, "{}", CodeFrame::new("python", &formatted_code)).unwrap();
|
||||||
|
|
||||||
write!(snapshot, "{}", Header::new("Black Output")).unwrap();
|
write!(snapshot, "{}", Header::new("Black Output")).unwrap();
|
||||||
write!(snapshot, "{}", CodeFrame::new("py", &expected_output)).unwrap();
|
write!(snapshot, "{}", CodeFrame::new("python", &expected_output)).unwrap();
|
||||||
|
|
||||||
insta::with_settings!({
|
insta::with_settings!({
|
||||||
omit_expression => true,
|
omit_expression => true,
|
||||||
|
@ -113,7 +113,7 @@ fn format() {
|
||||||
|
|
||||||
ensure_stability_when_formatting_twice(formatted_code, options.clone(), input_path);
|
ensure_stability_when_formatting_twice(formatted_code, options.clone(), input_path);
|
||||||
|
|
||||||
let mut snapshot = format!("## Input\n{}", CodeFrame::new("py", &content));
|
let mut snapshot = format!("## Input\n{}", CodeFrame::new("python", &content));
|
||||||
|
|
||||||
let options_path = input_path.with_extension("options.json");
|
let options_path = input_path.with_extension("options.json");
|
||||||
if let Ok(options_file) = fs::File::open(options_path) {
|
if let Ok(options_file) = fs::File::open(options_path) {
|
||||||
|
@ -135,7 +135,7 @@ fn format() {
|
||||||
"### Output {}\n{}{}",
|
"### Output {}\n{}{}",
|
||||||
i + 1,
|
i + 1,
|
||||||
CodeFrame::new("", &DisplayPyOptions(&options)),
|
CodeFrame::new("", &DisplayPyOptions(&options)),
|
||||||
CodeFrame::new("py", &formatted_code)
|
CodeFrame::new("python", &formatted_code)
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
@ -159,14 +159,19 @@ fn format() {
|
||||||
);
|
);
|
||||||
|
|
||||||
if formatted == formatted_preview {
|
if formatted == formatted_preview {
|
||||||
writeln!(snapshot, "## Output\n{}", CodeFrame::new("py", &formatted)).unwrap();
|
writeln!(
|
||||||
|
snapshot,
|
||||||
|
"## Output\n{}",
|
||||||
|
CodeFrame::new("python", &formatted)
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
} else {
|
} else {
|
||||||
// Having both snapshots makes it hard to see the difference, so we're keeping only
|
// Having both snapshots makes it hard to see the difference, so we're keeping only
|
||||||
// diff.
|
// diff.
|
||||||
writeln!(
|
writeln!(
|
||||||
snapshot,
|
snapshot,
|
||||||
"## Output\n{}\n## Preview changes\n{}",
|
"## Output\n{}\n## Preview changes\n{}",
|
||||||
CodeFrame::new("py", &formatted),
|
CodeFrame::new("python", &formatted),
|
||||||
CodeFrame::new(
|
CodeFrame::new(
|
||||||
"diff",
|
"diff",
|
||||||
TextDiff::from_lines(formatted, formatted_preview)
|
TextDiff::from_lines(formatted, formatted_preview)
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/condition
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
long_kwargs_single_line = my_function(
|
long_kwargs_single_line = my_function(
|
||||||
foo="test, this is a sample value",
|
foo="test, this is a sample value",
|
||||||
bar=some_long_value_name_foo_bar_baz if some_boolean_variable else some_fallback_value_foo_bar_baz,
|
bar=some_long_value_name_foo_bar_baz if some_boolean_variable else some_fallback_value_foo_bar_baz,
|
||||||
|
@ -149,7 +149,7 @@ def something():
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
long_kwargs_single_line = my_function(
|
long_kwargs_single_line = my_function(
|
||||||
foo="test, this is a sample value",
|
foo="test, this is a sample value",
|
||||||
bar=some_long_value_name_foo_bar_baz
|
bar=some_long_value_name_foo_bar_baz
|
||||||
|
@ -238,7 +238,7 @@ def something():
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
long_kwargs_single_line = my_function(
|
long_kwargs_single_line = my_function(
|
||||||
foo="test, this is a sample value",
|
foo="test, this is a sample value",
|
||||||
bar=(
|
bar=(
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def abc ():
|
def abc ():
|
||||||
return ["hello", "world",
|
return ["hello", "world",
|
||||||
"!"]
|
"!"]
|
||||||
|
@ -33,7 +33,7 @@ print( "Incorrect formatting"
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def abc():
|
def abc():
|
||||||
return ["hello", "world", "!"]
|
return ["hello", "world", "!"]
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ print("Incorrect formatting")
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def abc ():
|
def abc ():
|
||||||
return ["hello", "world",
|
return ["hello", "world",
|
||||||
"!"]
|
"!"]
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
@dataclass
|
@dataclass
|
||||||
class DebugVisitor(Visitor[T]):
|
class DebugVisitor(Visitor[T]):
|
||||||
tree_depth: int = 0
|
tree_depth: int = 0
|
||||||
|
@ -79,7 +79,7 @@ class DebugVisitor(Visitor[T]):
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
@dataclass
|
@dataclass
|
||||||
class DebugVisitor(Visitor[T]):
|
class DebugVisitor(Visitor[T]):
|
||||||
tree_depth: int = 0
|
tree_depth: int = 0
|
||||||
|
@ -116,7 +116,7 @@ class DebugVisitor(Visitor[T]):
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
@dataclass
|
@dataclass
|
||||||
class DebugVisitor(Visitor[T]):
|
class DebugVisitor(Visitor[T]):
|
||||||
tree_depth: int = 0
|
tree_depth: int = 0
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# This file doesn't use the standard decomposition.
|
# This file doesn't use the standard decomposition.
|
||||||
# Decorator syntax test cases are separated by double # comments.
|
# Decorator syntax test cases are separated by double # comments.
|
||||||
# Those before the 'output' comment are valid under the old syntax.
|
# Those before the 'output' comment are valid under the old syntax.
|
||||||
|
@ -378,7 +378,7 @@ def f():
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# This file doesn't use the standard decomposition.
|
# This file doesn't use the standard decomposition.
|
||||||
# Decorator syntax test cases are separated by double # comments.
|
# Decorator syntax test cases are separated by double # comments.
|
||||||
# Those before the 'output' comment are valid under the old syntax.
|
# Those before the 'output' comment are valid under the old syntax.
|
||||||
|
@ -589,7 +589,7 @@ def f():
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
##
|
##
|
||||||
|
|
||||||
@decorator()()
|
@decorator()()
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
class ALonelyClass:
|
class ALonelyClass:
|
||||||
'''
|
'''
|
||||||
A multiline class docstring.
|
A multiline class docstring.
|
||||||
|
@ -208,7 +208,7 @@ def multiline_backslash_3():
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
class ALonelyClass:
|
class ALonelyClass:
|
||||||
"""
|
"""
|
||||||
A multiline class docstring.
|
A multiline class docstring.
|
||||||
|
@ -336,7 +336,7 @@ def multiline_backslash_3():
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
class ALonelyClass:
|
class ALonelyClass:
|
||||||
'''
|
'''
|
||||||
A multiline class docstring.
|
A multiline class docstring.
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def do_not_touch_this_prefix():
|
def do_not_touch_this_prefix():
|
||||||
R"""There was a bug where docstring prefixes would be normalized even with -S."""
|
R"""There was a bug where docstring prefixes would be normalized even with -S."""
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ def do_not_touch_this_prefix3():
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def do_not_touch_this_prefix():
|
def do_not_touch_this_prefix():
|
||||||
R"""There was a bug where docstring prefixes would be normalized even with -S."""
|
R"""There was a bug where docstring prefixes would be normalized even with -S."""
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ def do_not_touch_this_prefix3():
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def do_not_touch_this_prefix():
|
def do_not_touch_this_prefix():
|
||||||
R"""There was a bug where docstring prefixes would be normalized even with -S."""
|
R"""There was a bug where docstring prefixes would be normalized even with -S."""
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# flags: --pyi
|
# flags: --pyi
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ def eggs() -> Union[str, int]: ...
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# flags: --pyi
|
# flags: --pyi
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ def eggs() -> Union[str, int]:
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
@bird
|
@bird
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
x = "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three."
|
x = "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three."
|
||||||
|
|
||||||
x += "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three."
|
x += "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three."
|
||||||
|
@ -324,7 +324,7 @@ long_unmergable_string_with_pragma = (
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
x = "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three."
|
x = "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three."
|
||||||
|
|
||||||
x += "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three."
|
x += "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three."
|
||||||
|
@ -617,7 +617,7 @@ long_unmergable_string_with_pragma = (
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
x = "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three."
|
x = "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three."
|
||||||
|
|
||||||
x += "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three."
|
x += "This is a really long string that can't possibly be expected to fit all together on one line. In fact it may even take up three or more lines... like four or five... but probably just three."
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
importA;()<<0**0#
|
importA;()<<0**0#
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -25,14 +25,14 @@ importA;()<<0**0#
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
importA
|
importA
|
||||||
() << 0**0 #
|
() << 0**0 #
|
||||||
```
|
```
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
importA
|
importA
|
||||||
(
|
(
|
||||||
()
|
()
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
''''''
|
''''''
|
||||||
|
|
||||||
'\''
|
'\''
|
||||||
|
@ -88,7 +88,7 @@ f"\"{a}\"{'hello' * b}\"{c}\""
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
""""""
|
""""""
|
||||||
|
|
||||||
"'"
|
"'"
|
||||||
|
@ -151,7 +151,7 @@ f"\"{a}\"{'hello' * b}\"{c}\""
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
""""""
|
""""""
|
||||||
|
|
||||||
"'"
|
"'"
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/py_310/pa
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
import match
|
import match
|
||||||
|
|
||||||
match something:
|
match something:
|
||||||
|
@ -162,7 +162,7 @@ match bar1:
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
import match
|
import match
|
||||||
|
|
||||||
match something:
|
match something:
|
||||||
|
@ -295,7 +295,7 @@ match bar1:
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
import match
|
import match
|
||||||
|
|
||||||
match something:
|
match something:
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/py_310/pa
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
match something:
|
match something:
|
||||||
case b(): print(1+1)
|
case b(): print(1+1)
|
||||||
case c(
|
case c(
|
||||||
|
@ -99,7 +99,7 @@ match match(
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
match something:
|
match something:
|
||||||
case b():
|
case b():
|
||||||
print(1 + 1)
|
print(1 + 1)
|
||||||
|
@ -145,7 +145,7 @@ match match():
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
match something:
|
match something:
|
||||||
case b():
|
case b():
|
||||||
print(1 + 1)
|
print(1 + 1)
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/py_310/pe
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# Unparenthesized walruses are now allowed in indices since Python 3.10.
|
# Unparenthesized walruses are now allowed in indices since Python 3.10.
|
||||||
x[a:=0]
|
x[a:=0]
|
||||||
x[a:=0, b:=1]
|
x[a:=0, b:=1]
|
||||||
|
@ -42,7 +42,7 @@ f(x, (a := b + c for c in range(10)), y=z, **q)
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# Unparenthesized walruses are now allowed in indices since Python 3.10.
|
# Unparenthesized walruses are now allowed in indices since Python 3.10.
|
||||||
x[a := 0]
|
x[a := 0]
|
||||||
x[a := 0, b := 1]
|
x[a := 0, b := 1]
|
||||||
|
@ -62,7 +62,7 @@ f(x, (a := b + c for c in range(10)), y=z, **q)
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# Unparenthesized walruses are now allowed in indices since Python 3.10.
|
# Unparenthesized walruses are now allowed in indices since Python 3.10.
|
||||||
x[a:=0]
|
x[a:=0]
|
||||||
x[a:=0, b:=1]
|
x[a:=0, b:=1]
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/py_38/pep
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
if (foo := 0):
|
if (foo := 0):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ async def await_the_walrus():
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
if foo := 0:
|
if foo := 0:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ async def await_the_walrus():
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
if foo := 0:
|
if foo := 0:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/raw_docst
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# flags: --preview --skip-string-normalization
|
# flags: --preview --skip-string-normalization
|
||||||
class C:
|
class C:
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class UpperCaseR:
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# flags: --preview --skip-string-normalization
|
# flags: --preview --skip-string-normalization
|
||||||
class C:
|
class C:
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ class UpperCaseR:
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
class C:
|
class C:
|
||||||
r"""Raw"""
|
r"""Raw"""
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def bob(): \
|
def bob(): \
|
||||||
# pylint: disable=W9016
|
# pylint: disable=W9016
|
||||||
pass
|
pass
|
||||||
|
@ -36,7 +36,7 @@ def bobtwo(): \
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def bob():
|
def bob():
|
||||||
# pylint: disable=W9016
|
# pylint: disable=W9016
|
||||||
pass
|
pass
|
||||||
|
@ -49,7 +49,7 @@ def bobtwo():
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def bob(): # pylint: disable=W9016
|
def bob(): # pylint: disable=W9016
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
||||||
MyLovelyCompanyTeamProjectComponent # NOT DRY
|
MyLovelyCompanyTeamProjectComponent # NOT DRY
|
||||||
)
|
)
|
||||||
|
@ -246,7 +246,7 @@ instruction()#comment with bad spacing
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
||||||
MyLovelyCompanyTeamProjectComponent, # NOT DRY
|
MyLovelyCompanyTeamProjectComponent, # NOT DRY
|
||||||
)
|
)
|
||||||
|
@ -442,7 +442,7 @@ instruction() # comment with bad spacing
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
||||||
MyLovelyCompanyTeamProjectComponent, # NOT DRY
|
MyLovelyCompanyTeamProjectComponent, # NOT DRY
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
from typing import Any, Tuple
|
from typing import Any, Tuple
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ aaaaaaaaaaaaa, bbbbbbbbb = map(list, map(itertools.chain.from_iterable, zip(*ite
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
from typing import Any, Tuple
|
from typing import Any, Tuple
|
||||||
|
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ aaaaaaaaaaaaa, bbbbbbbbb = map(list, map(itertools.chain.from_iterable, zip(*ite
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
from typing import Any, Tuple
|
from typing import Any, Tuple
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# Test for https://github.com/psf/black/issues/246.
|
# Test for https://github.com/psf/black/issues/246.
|
||||||
|
|
||||||
some = statement
|
some = statement
|
||||||
|
@ -179,7 +179,7 @@ def bar():
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# Test for https://github.com/psf/black/issues/246.
|
# Test for https://github.com/psf/black/issues/246.
|
||||||
|
|
||||||
some = statement
|
some = statement
|
||||||
|
@ -342,7 +342,7 @@ def bar():
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# Test for https://github.com/psf/black/issues/246.
|
# Test for https://github.com/psf/black/issues/246.
|
||||||
|
|
||||||
some = statement
|
some = statement
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
class C:
|
class C:
|
||||||
def test(self) -> None:
|
def test(self) -> None:
|
||||||
with patch("black.out", print):
|
with patch("black.out", print):
|
||||||
|
@ -242,7 +242,7 @@ class C:
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
class C:
|
class C:
|
||||||
def test(self) -> None:
|
def test(self) -> None:
|
||||||
with patch("black.out", print):
|
with patch("black.out", print):
|
||||||
|
@ -427,7 +427,7 @@ class C:
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
class C:
|
class C:
|
||||||
def test(self) -> None:
|
def test(self) -> None:
|
||||||
with patch("black.out", print):
|
with patch("black.out", print):
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
class C:
|
class C:
|
||||||
def test(self) -> None:
|
def test(self) -> None:
|
||||||
with patch("black.out", print):
|
with patch("black.out", print):
|
||||||
|
@ -242,7 +242,7 @@ class C:
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
class C:
|
class C:
|
||||||
def test(self) -> None:
|
def test(self) -> None:
|
||||||
with patch("black.out", print):
|
with patch("black.out", print):
|
||||||
|
@ -427,7 +427,7 @@ class C:
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
class C:
|
class C:
|
||||||
def test(self) -> None:
|
def test(self) -> None:
|
||||||
with patch("black.out", print):
|
with patch("black.out", print):
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def docstring_almost_at_line_limit():
|
def docstring_almost_at_line_limit():
|
||||||
"""long docstring.................................................................
|
"""long docstring.................................................................
|
||||||
"""
|
"""
|
||||||
|
@ -76,7 +76,7 @@ def single_quote_docstring_over_line_limit2():
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def docstring_almost_at_line_limit():
|
def docstring_almost_at_line_limit():
|
||||||
"""long docstring................................................................."""
|
"""long docstring................................................................."""
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ def single_quote_docstring_over_line_limit2():
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def docstring_almost_at_line_limit():
|
def docstring_almost_at_line_limit():
|
||||||
"""long docstring................................................................."""
|
"""long docstring................................................................."""
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
...
|
...
|
||||||
'some_string'
|
'some_string'
|
||||||
b'\\xa3'
|
b'\\xa3'
|
||||||
|
@ -279,7 +279,7 @@ last_call()
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
...
|
...
|
||||||
"some_string"
|
"some_string"
|
||||||
b"\\xa3"
|
b"\\xa3"
|
||||||
|
@ -655,7 +655,7 @@ last_call()
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
...
|
...
|
||||||
"some_string"
|
"some_string"
|
||||||
b"\\xa3"
|
b"\\xa3"
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import asyncio
|
import asyncio
|
||||||
import sys
|
import sys
|
||||||
|
@ -271,7 +271,7 @@ d={'a':1,
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import asyncio
|
import asyncio
|
||||||
import sys
|
import sys
|
||||||
|
@ -506,7 +506,7 @@ d={'a':1,
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import asyncio
|
import asyncio
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# fmt: off
|
# fmt: off
|
||||||
@test([
|
@test([
|
||||||
1, 2,
|
1, 2,
|
||||||
|
@ -53,7 +53,7 @@ def f(): pass
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# fmt: off
|
# fmt: off
|
||||||
@test([
|
@test([
|
||||||
1, 2,
|
1, 2,
|
||||||
|
@ -71,7 +71,7 @@ def f(): pass
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# fmt: off
|
# fmt: off
|
||||||
@test([
|
@test([
|
||||||
1, 2,
|
1, 2,
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# Regression test for https://github.com/psf/black/issues/3129.
|
# Regression test for https://github.com/psf/black/issues/3129.
|
||||||
setup(
|
setup(
|
||||||
entry_points={
|
entry_points={
|
||||||
|
@ -122,7 +122,7 @@ elif unformatted:
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# Regression test for https://github.com/psf/black/issues/3129.
|
# Regression test for https://github.com/psf/black/issues/3129.
|
||||||
setup(
|
setup(
|
||||||
entry_points={
|
entry_points={
|
||||||
|
@ -213,7 +213,7 @@ elif unformatted:
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# Regression test for https://github.com/psf/black/issues/3129.
|
# Regression test for https://github.com/psf/black/issues/3129.
|
||||||
setup(
|
setup(
|
||||||
entry_points={
|
entry_points={
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# Regression test for https://github.com/psf/black/issues/3438
|
# Regression test for https://github.com/psf/black/issues/3438
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
|
@ -43,7 +43,7 @@ import zoneinfo
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# Regression test for https://github.com/psf/black/issues/3438
|
# Regression test for https://github.com/psf/black/issues/3438
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
|
@ -68,7 +68,7 @@ import zoneinfo
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# Regression test for https://github.com/psf/black/issues/3438
|
# Regression test for https://github.com/psf/black/issues/3438
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
a, b, c = 3, 4, 5
|
a, b, c = 3, 4, 5
|
||||||
if (
|
if (
|
||||||
a == 3
|
a == 3
|
||||||
|
@ -34,7 +34,7 @@ else:
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
a, b, c = 3, 4, 5
|
a, b, c = 3, 4, 5
|
||||||
if (
|
if (
|
||||||
a == 3
|
a == 3
|
||||||
|
@ -48,7 +48,7 @@ else:
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
a, b, c = 3, 4, 5
|
a, b, c = 3, 4, 5
|
||||||
if (
|
if (
|
||||||
a == 3
|
a == 3
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import asyncio
|
import asyncio
|
||||||
import sys
|
import sys
|
||||||
|
@ -119,7 +119,7 @@ def __await__(): return (yield)
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import asyncio
|
import asyncio
|
||||||
import sys
|
import sys
|
||||||
|
@ -273,7 +273,7 @@ def __await__():
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import asyncio
|
import asyncio
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def f(
|
def f(
|
||||||
a,
|
a,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
|
@ -85,7 +85,7 @@ with hmm_but_this_should_get_two_preceding_newlines():
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def f(
|
def f(
|
||||||
a,
|
a,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
|
@ -153,7 +153,7 @@ with hmm_but_this_should_get_two_preceding_newlines():
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def f(
|
def f(
|
||||||
a,
|
a,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def f(): # type: ignore
|
def f(): # type: ignore
|
||||||
...
|
...
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ def h():
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def f(): # type: ignore
|
def f(): # type: ignore
|
||||||
...
|
...
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ def h():
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def f(): # type: ignore
|
def f(): # type: ignore
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# This is a regression test. Issue #3737
|
# This is a regression test. Issue #3737
|
||||||
|
|
||||||
a = ( # type: ignore
|
a = ( # type: ignore
|
||||||
|
@ -48,7 +48,7 @@ print( "111" ) # type: ignore
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# This is a regression test. Issue #3737
|
# This is a regression test. Issue #3737
|
||||||
|
|
||||||
a = ( # type: ignore
|
a = ( # type: ignore
|
||||||
|
@ -70,7 +70,7 @@ print("111") # type: ignore
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# This is a regression test. Issue #3737
|
# This is a regression test. Issue #3737
|
||||||
|
|
||||||
a = ( # type: ignore
|
a = ( # type: ignore
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
# Control example
|
# Control example
|
||||||
|
@ -108,7 +108,7 @@ async def main():
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ async def main():
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# These brackets are redundant, therefore remove.
|
# These brackets are redundant, therefore remove.
|
||||||
try:
|
try:
|
||||||
a.something
|
a.something
|
||||||
|
@ -62,7 +62,7 @@ except (some.really.really.really.looooooooooooooooooooooooooooooooong.module.ov
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# These brackets are redundant, therefore remove.
|
# These brackets are redundant, therefore remove.
|
||||||
try:
|
try:
|
||||||
a.something
|
a.something
|
||||||
|
@ -107,7 +107,7 @@ except (
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# These brackets are redundant, therefore remove.
|
# These brackets are redundant, therefore remove.
|
||||||
try:
|
try:
|
||||||
a.something
|
a.something
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# Only remove tuple brackets after `for`
|
# Only remove tuple brackets after `for`
|
||||||
for (k, v) in d.items():
|
for (k, v) in d.items():
|
||||||
print(k, v)
|
print(k, v)
|
||||||
|
@ -46,7 +46,7 @@ for (((((k, v))))) in d.items():
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# Only remove tuple brackets after `for`
|
# Only remove tuple brackets after `for`
|
||||||
for k, v in d.items():
|
for k, v in d.items():
|
||||||
print(k, v)
|
print(k, v)
|
||||||
|
@ -76,7 +76,7 @@ for k, v in d.items():
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# Only remove tuple brackets after `for`
|
# Only remove tuple brackets after `for`
|
||||||
for k, v in d.items():
|
for k, v in d.items():
|
||||||
print(k, v)
|
print(k, v)
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# Control
|
# Control
|
||||||
def double(a: int) -> int:
|
def double(a: int) -> int:
|
||||||
return 2*a
|
return 2*a
|
||||||
|
@ -126,7 +126,7 @@ def foo() -> tuple[int, int, int,]:
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# Control
|
# Control
|
||||||
def double(a: int) -> int:
|
def double(a: int) -> int:
|
||||||
return 2 * a
|
return 2 * a
|
||||||
|
@ -259,7 +259,7 @@ def foo() -> (
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# Control
|
# Control
|
||||||
def double(a: int) -> int:
|
def double(a: int) -> int:
|
||||||
return 2 * a
|
return 2 * a
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
importA;() << 0 ** 101234234242352525425252352352525234890264906820496920680926538059059209922523523525 #
|
importA;() << 0 ** 101234234242352525425252352352525234890264906820496920680926538059059209922523523525 #
|
||||||
|
|
||||||
assert sort_by_dependency(
|
assert sort_by_dependency(
|
||||||
|
@ -66,7 +66,7 @@ assert (
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
importA
|
importA
|
||||||
(
|
(
|
||||||
()
|
()
|
||||||
|
@ -129,7 +129,7 @@ assert a_function(
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
importA
|
importA
|
||||||
(
|
(
|
||||||
()
|
()
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
zero(one,).two(three,).four(five,)
|
zero(one,).two(three,).four(five,)
|
||||||
|
|
||||||
func1(arg1).func2(arg2,).func3(arg3).func4(arg4,).func5(arg5)
|
func1(arg1).func2(arg2,).func3(arg3).func4(arg4,).func5(arg5)
|
||||||
|
@ -72,7 +72,7 @@ assert xxxxxxxxx.xxxxxxxxx.xxxxxxxxx(
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
zero(
|
zero(
|
||||||
one,
|
one,
|
||||||
).two(
|
).two(
|
||||||
|
@ -123,7 +123,7 @@ assert (
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
zero(
|
zero(
|
||||||
one,
|
one,
|
||||||
).two(
|
).two(
|
||||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# This is a standalone comment.
|
# This is a standalone comment.
|
||||||
sdfjklsdfsjldkflkjsf, sdfjsdfjlksdljkfsdlkf, sdfsdjfklsdfjlksdljkf, sdsfsdfjskdflsfsdf = 1, 2, 3
|
sdfjklsdfsjldkflkjsf, sdfjsdfjlksdljkfsdlkf, sdfsdjfklsdfjlksdljkf, sdsfsdfjskdflsfsdf = 1, 2, 3
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ this_will_be_wrapped_in_parens, = struct.unpack(b"12345678901234567890")
|
||||||
|
|
||||||
## Ruff Output
|
## Ruff Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# This is a standalone comment.
|
# This is a standalone comment.
|
||||||
(
|
(
|
||||||
sdfjklsdfsjldkflkjsf,
|
sdfjklsdfsjldkflkjsf,
|
||||||
|
@ -49,7 +49,7 @@ this_will_be_wrapped_in_parens, = struct.unpack(b"12345678901234567890")
|
||||||
|
|
||||||
## Black Output
|
## Black Output
|
||||||
|
|
||||||
```py
|
```python
|
||||||
# This is a standalone comment.
|
# This is a standalone comment.
|
||||||
(
|
(
|
||||||
sdfjklsdfsjldkflkjsf,
|
sdfjklsdfsjldkflkjsf,
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/carriage_return/string.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/carriage_return/string.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
'This string will not include \
|
'This string will not include \
|
||||||
backslashes or newline characters.'
|
backslashes or newline characters.'
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ String \"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
"This string will not include \
|
"This string will not include \
|
||||||
backslashes or newline characters."
|
backslashes or newline characters."
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/docstring.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
def single_line_backslashes1():
|
def single_line_backslashes1():
|
||||||
""" content\ """
|
""" content\ """
|
||||||
return
|
return
|
||||||
|
@ -169,7 +169,7 @@ magic-trailing-comma = Respect
|
||||||
preview = Disabled
|
preview = Disabled
|
||||||
```
|
```
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def single_line_backslashes1():
|
def single_line_backslashes1():
|
||||||
"""content\ """
|
"""content\ """
|
||||||
return
|
return
|
||||||
|
@ -335,7 +335,7 @@ magic-trailing-comma = Respect
|
||||||
preview = Disabled
|
preview = Disabled
|
||||||
```
|
```
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def single_line_backslashes1():
|
def single_line_backslashes1():
|
||||||
"""content\ """
|
"""content\ """
|
||||||
return
|
return
|
||||||
|
@ -501,7 +501,7 @@ magic-trailing-comma = Respect
|
||||||
preview = Disabled
|
preview = Disabled
|
||||||
```
|
```
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def single_line_backslashes1():
|
def single_line_backslashes1():
|
||||||
"""content\ """
|
"""content\ """
|
||||||
return
|
return
|
||||||
|
@ -667,7 +667,7 @@ magic-trailing-comma = Respect
|
||||||
preview = Disabled
|
preview = Disabled
|
||||||
```
|
```
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def single_line_backslashes1():
|
def single_line_backslashes1():
|
||||||
"""content\ """
|
"""content\ """
|
||||||
return
|
return
|
||||||
|
|
|
@ -3,14 +3,14 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/empty_multiple_trailing_newlines.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/empty_multiple_trailing_newlines.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,11 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/empty_now_newline.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/empty_now_newline.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,12 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/empty_trailing_newline.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/empty_trailing_newline.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,11 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/empty_whitespace.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/empty_whitespace.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/annotated_assign.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/annotated_assign.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
a: string
|
a: string
|
||||||
|
|
||||||
b: string = "test"
|
b: string = "test"
|
||||||
|
@ -20,7 +20,7 @@ b: list[
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
a: string
|
a: string
|
||||||
|
|
||||||
b: string = "test"
|
b: string = "test"
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/attribute.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/attribute.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
from argparse import Namespace
|
from argparse import Namespace
|
||||||
|
|
||||||
a = Namespace()
|
a = Namespace()
|
||||||
|
@ -161,7 +161,7 @@ result = (
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
from argparse import Namespace
|
from argparse import Namespace
|
||||||
|
|
||||||
a = Namespace()
|
a = Namespace()
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/await.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/await.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
# Regression test for: https://github.com/astral-sh/ruff/issues/7420
|
# Regression test for: https://github.com/astral-sh/ruff/issues/7420
|
||||||
result = await self.request(
|
result = await self.request(
|
||||||
f"/applications/{int(application_id)}/guilds/{int(scope)}/commands/{int(command_id)}/permissions"
|
f"/applications/{int(application_id)}/guilds/{int(scope)}/commands/{int(command_id)}/permissions"
|
||||||
|
@ -57,7 +57,7 @@ await (
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
# Regression test for: https://github.com/astral-sh/ruff/issues/7420
|
# Regression test for: https://github.com/astral-sh/ruff/issues/7420
|
||||||
result = await self.request(
|
result = await self.request(
|
||||||
f"/applications/{int(application_id)}/guilds/{int(scope)}/commands/{int(command_id)}/permissions"
|
f"/applications/{int(application_id)}/guilds/{int(scope)}/commands/{int(command_id)}/permissions"
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
(aaaaaaaa
|
(aaaaaaaa
|
||||||
+ # trailing operator comment
|
+ # trailing operator comment
|
||||||
b # trailing right comment
|
b # trailing right comment
|
||||||
|
@ -415,7 +415,7 @@ if True:
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
(
|
(
|
||||||
aaaaaaaa
|
aaaaaaaa
|
||||||
+ # trailing operator comment
|
+ # trailing operator comment
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary_implicit_string.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary_implicit_string.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
|
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
"The app module %r has multiple filesystem locations (%r); "
|
"The app module %r has multiple filesystem locations (%r); "
|
||||||
|
@ -198,7 +198,7 @@ class EC2REPATH:
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
"The app module %r has multiple filesystem locations (%r); "
|
"The app module %r has multiple filesystem locations (%r); "
|
||||||
"you must configure this app with an AppConfig subclass "
|
"you must configure this app with an AppConfig subclass "
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary_pow_spacing.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary_pow_spacing.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
# No spacing
|
# No spacing
|
||||||
5 ** 5
|
5 ** 5
|
||||||
5.0 ** 5.0
|
5.0 ** 5.0
|
||||||
|
@ -17,7 +17,7 @@ None ** None
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
# No spacing
|
# No spacing
|
||||||
5**5
|
5**5
|
||||||
5.0**5.0
|
5.0**5.0
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/boolean_operation.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/boolean_operation.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
if (
|
if (
|
||||||
self._proc
|
self._proc
|
||||||
# has the child process finished?
|
# has the child process finished?
|
||||||
|
@ -194,7 +194,7 @@ if (self._proc
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
if (
|
if (
|
||||||
self._proc
|
self._proc
|
||||||
# has the child process finished?
|
# has the child process finished?
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/bytes.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/bytes.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
b"' test"
|
b"' test"
|
||||||
b'" test'
|
b'" test'
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ magic-trailing-comma = Respect
|
||||||
preview = Disabled
|
preview = Disabled
|
||||||
```
|
```
|
||||||
|
|
||||||
```py
|
```python
|
||||||
b"' test"
|
b"' test"
|
||||||
b'" test'
|
b'" test'
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ magic-trailing-comma = Respect
|
||||||
preview = Disabled
|
preview = Disabled
|
||||||
```
|
```
|
||||||
|
|
||||||
```py
|
```python
|
||||||
b"' test"
|
b"' test"
|
||||||
b'" test'
|
b'" test'
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/call.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/call.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ result = (object[complicate_caller])("argument").a["b"].test(argument)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/compare.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/compare.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
a == b
|
a == b
|
||||||
a != b
|
a != b
|
||||||
a < b
|
a < b
|
||||||
|
@ -187,7 +187,7 @@ c = (a *
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
a == b
|
a == b
|
||||||
a != b
|
a != b
|
||||||
a < b
|
a < b
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/dict.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/dict.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
# before
|
# before
|
||||||
{ # open
|
{ # open
|
||||||
key# key
|
key# key
|
||||||
|
@ -141,7 +141,7 @@ query = {
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
# before
|
# before
|
||||||
{ # open
|
{ # open
|
||||||
key: # key
|
key: # key
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/dict_comp.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/dict_comp.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
{i: i for i in []}
|
{i: i for i in []}
|
||||||
|
|
||||||
{i: i for i in [1,]}
|
{i: i for i in [1,]}
|
||||||
|
@ -186,7 +186,7 @@ query = {
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
{i: i for i in []}
|
{i: i for i in []}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/fstring.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
(
|
(
|
||||||
f'{one}'
|
f'{one}'
|
||||||
f'{two}'
|
f'{two}'
|
||||||
|
@ -71,7 +71,7 @@ z = f'''a{""}b''' f'''c{1}d"""e'''
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
(f"{one}" f"{two}")
|
(f"{one}" f"{two}")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/generator_exp.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/generator_exp.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
(a for b in c)
|
(a for b in c)
|
||||||
|
|
||||||
# parens around generator expression not required
|
# parens around generator expression not required
|
||||||
|
@ -78,7 +78,7 @@ tuple(
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
(a for b in c)
|
(a for b in c)
|
||||||
|
|
||||||
# parens around generator expression not required
|
# parens around generator expression not required
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/if.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/if.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
a1 = 1 if True else 2
|
a1 = 1 if True else 2
|
||||||
|
|
||||||
a2 = "this is a very long text that will make the group break to check that parentheses are added" if True else 2
|
a2 = "this is a very long text that will make the group break to check that parentheses are added" if True else 2
|
||||||
|
@ -117,7 +117,7 @@ def something():
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
a1 = 1 if True else 2
|
a1 = 1 if True else 2
|
||||||
|
|
||||||
a2 = (
|
a2 = (
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/lambda.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/lambda.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
# Leading
|
# Leading
|
||||||
lambda x: x # Trailing
|
lambda x: x # Trailing
|
||||||
# Trailing
|
# Trailing
|
||||||
|
@ -237,7 +237,7 @@ def a():
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
# Leading
|
# Leading
|
||||||
lambda x: x # Trailing
|
lambda x: x # Trailing
|
||||||
# Trailing
|
# Trailing
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/list.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/list.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
# Dangling comment placement in empty lists
|
# Dangling comment placement in empty lists
|
||||||
# Regression test for https://github.com/python/cpython/blob/03160630319ca26dcbbad65225da4248e54c45ec/Tools/c-analyzer/c_analyzer/datafiles.py#L14-L16
|
# Regression test for https://github.com/python/cpython/blob/03160630319ca26dcbbad65225da4248e54c45ec/Tools/c-analyzer/c_analyzer/datafiles.py#L14-L16
|
||||||
a1 = [ # a
|
a1 = [ # a
|
||||||
|
@ -67,7 +67,7 @@ c1 = [ # trailing open bracket
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
# Dangling comment placement in empty lists
|
# Dangling comment placement in empty lists
|
||||||
# Regression test for https://github.com/python/cpython/blob/03160630319ca26dcbbad65225da4248e54c45ec/Tools/c-analyzer/c_analyzer/datafiles.py#L14-L16
|
# Regression test for https://github.com/python/cpython/blob/03160630319ca26dcbbad65225da4248e54c45ec/Tools/c-analyzer/c_analyzer/datafiles.py#L14-L16
|
||||||
a1 = [ # a
|
a1 = [ # a
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/list_comp.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/list_comp.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
[i for i in []]
|
[i for i in []]
|
||||||
|
|
||||||
[i for i in [1,]]
|
[i for i in [1,]]
|
||||||
|
@ -114,7 +114,7 @@ aaaaaaaaaaaaaaaaaaaaa = [
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
[i for i in []]
|
[i for i in []]
|
||||||
|
|
||||||
[
|
[
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/named_expr.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/named_expr.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
y = 1
|
y = 1
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -106,7 +106,7 @@ async def f():
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
y = 1
|
y = 1
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/number.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/number.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
.1
|
.1
|
||||||
1.
|
1.
|
||||||
1E+1
|
1E+1
|
||||||
|
@ -14,7 +14,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
0.1
|
0.1
|
||||||
1.0
|
1.0
|
||||||
1e1
|
1e1
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/optional_parentheses_comments.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/optional_parentheses_comments.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
comment_string = "Long lines with inline comments should have their comments appended to the reformatted string's enclosing right parentheses." # This comment gets thrown to the top.
|
comment_string = "Long lines with inline comments should have their comments appended to the reformatted string's enclosing right parentheses." # This comment gets thrown to the top.
|
||||||
|
|
||||||
# 88 characters unparenthesized
|
# 88 characters unparenthesized
|
||||||
|
@ -213,7 +213,7 @@ def test6():
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
comment_string = "Long lines with inline comments should have their comments appended to the reformatted string's enclosing right parentheses." # This comment gets thrown to the top.
|
comment_string = "Long lines with inline comments should have their comments appended to the reformatted string's enclosing right parentheses." # This comment gets thrown to the top.
|
||||||
|
|
||||||
# 88 characters unparenthesized
|
# 88 characters unparenthesized
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/set_comp.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/set_comp.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
{i for i in []}
|
{i for i in []}
|
||||||
|
|
||||||
{i for i in [1,]}
|
{i for i in [1,]}
|
||||||
|
@ -62,7 +62,7 @@ selected_choices = {
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
{i for i in []}
|
{i for i in []}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/slice.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/slice.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
# Handle comments both when lower and upper exist and when they don't
|
# Handle comments both when lower and upper exist and when they don't
|
||||||
a1 = "a"[
|
a1 = "a"[
|
||||||
# a
|
# a
|
||||||
|
@ -119,7 +119,7 @@ self.assertEqual(
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
# Handle comments both when lower and upper exist and when they don't
|
# Handle comments both when lower and upper exist and when they don't
|
||||||
a1 = "a"[
|
a1 = "a"[
|
||||||
# a
|
# a
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/split_empty_brackets.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/split_empty_brackets.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
# Expressions with empty parentheses.
|
# Expressions with empty parentheses.
|
||||||
ct_match = (
|
ct_match = (
|
||||||
unicodedata.normalize("NFKC", s1).casefold()
|
unicodedata.normalize("NFKC", s1).casefold()
|
||||||
|
@ -97,7 +97,7 @@ response = await sync_to_async(
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
# Expressions with empty parentheses.
|
# Expressions with empty parentheses.
|
||||||
ct_match = (
|
ct_match = (
|
||||||
unicodedata.normalize("NFKC", s1).casefold()
|
unicodedata.normalize("NFKC", s1).casefold()
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/starred.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/starred.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
call(
|
call(
|
||||||
# Leading starred comment
|
# Leading starred comment
|
||||||
* # Trailing star comment
|
* # Trailing star comment
|
||||||
|
@ -40,7 +40,7 @@ call(
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
call(
|
call(
|
||||||
# Leading starred comment
|
# Leading starred comment
|
||||||
# Trailing star comment
|
# Trailing star comment
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/string.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/string.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
"' test"
|
"' test"
|
||||||
'" test'
|
'" test'
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ magic-trailing-comma = Respect
|
||||||
preview = Disabled
|
preview = Disabled
|
||||||
```
|
```
|
||||||
|
|
||||||
```py
|
```python
|
||||||
"' test"
|
"' test"
|
||||||
'" test'
|
'" test'
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ magic-trailing-comma = Respect
|
||||||
preview = Disabled
|
preview = Disabled
|
||||||
```
|
```
|
||||||
|
|
||||||
```py
|
```python
|
||||||
"' test"
|
"' test"
|
||||||
'" test'
|
'" test'
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/subscript.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/subscript.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
# Regression test for: https://github.com/astral-sh/ruff/issues/7370
|
# Regression test for: https://github.com/astral-sh/ruff/issues/7370
|
||||||
result = (
|
result = (
|
||||||
f(111111111111111111111111111111111111111111111111111111111111111111111111111111111)
|
f(111111111111111111111111111111111111111111111111111111111111111111111111111111111)
|
||||||
|
@ -12,7 +12,7 @@ result = (
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
# Regression test for: https://github.com/astral-sh/ruff/issues/7370
|
# Regression test for: https://github.com/astral-sh/ruff/issues/7370
|
||||||
result = (
|
result = (
|
||||||
f(111111111111111111111111111111111111111111111111111111111111111111111111111111111)
|
f(111111111111111111111111111111111111111111111111111111111111111111111111111111111)
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/tuple.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/tuple.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
# Non-wrapping parentheses checks
|
# Non-wrapping parentheses checks
|
||||||
a1 = 1, 2
|
a1 = 1, 2
|
||||||
a2 = (1, 2)
|
a2 = (1, 2)
|
||||||
|
@ -78,7 +78,7 @@ i1 = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
# Non-wrapping parentheses checks
|
# Non-wrapping parentheses checks
|
||||||
a1 = 1, 2
|
a1 = 1, 2
|
||||||
a2 = (1, 2)
|
a2 = (1, 2)
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/unary.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/unary.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
if not aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:
|
if not aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ def foo():
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
if (
|
if (
|
||||||
not aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
not aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/unsplittable.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/unsplittable.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
x = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
x = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
|
|
||||||
x_aa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
x_aa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
|
@ -103,7 +103,7 @@ def f():
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
x = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
x = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
|
|
||||||
x_aa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
x_aa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/yield.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/yield.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
l = [1,2,3,4]
|
l = [1,2,3,4]
|
||||||
|
|
||||||
def foo():
|
def foo():
|
||||||
|
@ -128,7 +128,7 @@ print((yield x))
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
l = [1, 2, 3, 4]
|
l = [1, 2, 3, 4]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/yield_from.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/yield_from.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
l = [1,2,3,4]
|
l = [1,2,3,4]
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ def foo():
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
l = [1, 2, 3, 4]
|
l = [1, 2, 3, 4]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/comments.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/comments.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
@ -35,7 +35,7 @@ def test():
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/empty_file.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/empty_file.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
|
||||||
# this does not work because there are no statements
|
# this does not work because there are no statements
|
||||||
|
@ -12,7 +12,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
|
||||||
# this does not work because there are no statements
|
# this does not work because there are no statements
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/fmt_off_docstring.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/fmt_off_docstring.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
def test():
|
def test():
|
||||||
# fmt: off
|
# fmt: off
|
||||||
""" This docstring does not
|
""" This docstring does not
|
||||||
|
@ -36,7 +36,7 @@ magic-trailing-comma = Respect
|
||||||
preview = Disabled
|
preview = Disabled
|
||||||
```
|
```
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def test():
|
def test():
|
||||||
# fmt: off
|
# fmt: off
|
||||||
""" This docstring does not
|
""" This docstring does not
|
||||||
|
@ -69,7 +69,7 @@ magic-trailing-comma = Respect
|
||||||
preview = Disabled
|
preview = Disabled
|
||||||
```
|
```
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def test():
|
def test():
|
||||||
# fmt: off
|
# fmt: off
|
||||||
""" This docstring does not
|
""" This docstring does not
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/fmt_off_unclosed_deep_nested_trailing_comment.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/fmt_off_unclosed_deep_nested_trailing_comment.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
# Regression test for https://github.com/astral-sh/ruff/issues/8211
|
# Regression test for https://github.com/astral-sh/ruff/issues/8211
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
@ -15,7 +15,7 @@ if True:
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
# Regression test for https://github.com/astral-sh/ruff/issues/8211
|
# Regression test for https://github.com/astral-sh/ruff/issues/8211
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/fmt_off_unclosed_trailing_comment.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/fmt_off_unclosed_trailing_comment.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
# Regression test for https://github.com/astral-sh/ruff/issues/8211
|
# Regression test for https://github.com/astral-sh/ruff/issues/8211
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
@ -15,7 +15,7 @@ class A:
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
# Regression test for https://github.com/astral-sh/ruff/issues/8211
|
# Regression test for https://github.com/astral-sh/ruff/issues/8211
|
||||||
|
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/form_feed.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/form_feed.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
# fmt: off
|
# fmt: off
|
||||||
# DB layer (form feed at the start of the next line)
|
# DB layer (form feed at the start of the next line)
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ def test():
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
# fmt: off
|
# fmt: off
|
||||||
# DB layer (form feed at the start of the next line)
|
# DB layer (form feed at the start of the next line)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/indent.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/indent.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
```
|
```
|
||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
@ -17,7 +17,7 @@ magic-trailing-comma = Respect
|
||||||
preview = Disabled
|
preview = Disabled
|
||||||
```
|
```
|
||||||
|
|
||||||
```py
|
```python
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ magic-trailing-comma = Respect
|
||||||
preview = Disabled
|
preview = Disabled
|
||||||
```
|
```
|
||||||
|
|
||||||
```py
|
```python
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ magic-trailing-comma = Respect
|
||||||
preview = Disabled
|
preview = Disabled
|
||||||
```
|
```
|
||||||
|
|
||||||
```py
|
```python
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/last_statement.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/last_statement.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
def test():
|
def test():
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ a + b # formatted
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
def test():
|
def test():
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/mixed_space_and_tab.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/mixed_space_and_tab.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
def test():
|
def test():
|
||||||
# fmt: off
|
# fmt: off
|
||||||
a_very_small_indent
|
a_very_small_indent
|
||||||
|
@ -32,7 +32,7 @@ magic-trailing-comma = Respect
|
||||||
preview = Disabled
|
preview = Disabled
|
||||||
```
|
```
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def test():
|
def test():
|
||||||
# fmt: off
|
# fmt: off
|
||||||
a_very_small_indent
|
a_very_small_indent
|
||||||
|
@ -62,7 +62,7 @@ magic-trailing-comma = Respect
|
||||||
preview = Disabled
|
preview = Disabled
|
||||||
```
|
```
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def test():
|
def test():
|
||||||
# fmt: off
|
# fmt: off
|
||||||
a_very_small_indent
|
a_very_small_indent
|
||||||
|
@ -92,7 +92,7 @@ magic-trailing-comma = Respect
|
||||||
preview = Disabled
|
preview = Disabled
|
||||||
```
|
```
|
||||||
|
|
||||||
```py
|
```python
|
||||||
def test():
|
def test():
|
||||||
# fmt: off
|
# fmt: off
|
||||||
a_very_small_indent
|
a_very_small_indent
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/newlines.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/newlines.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
def func():
|
def func():
|
||||||
pass
|
pass
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
@ -43,7 +43,7 @@ def func():
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
def func():
|
def func():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/no_fmt_on.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/no_fmt_on.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
def test():
|
def test():
|
||||||
# fmt: off
|
# fmt: off
|
||||||
not formatted
|
not formatted
|
||||||
|
@ -16,7 +16,7 @@ a + b
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
def test():
|
def test():
|
||||||
# fmt: off
|
# fmt: off
|
||||||
not formatted
|
not formatted
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/off_on_off_on.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/off_on_off_on.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
# Tricky sequences of fmt off and on
|
# Tricky sequences of fmt off and on
|
||||||
|
|
||||||
# Formatted
|
# Formatted
|
||||||
|
@ -78,7 +78,7 @@ a + b
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
# Tricky sequences of fmt off and on
|
# Tricky sequences of fmt off and on
|
||||||
|
|
||||||
# Formatted
|
# Formatted
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/simple.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/simple.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
# Get's formatted
|
# Get's formatted
|
||||||
a + b
|
a + b
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ a + b
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
# Get's formatted
|
# Get's formatted
|
||||||
a + b
|
a + b
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/trailing_comments.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/trailing_comments.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
a = 10
|
a = 10
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ def test3 ():
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
a = 10
|
a = 10
|
||||||
# fmt: off
|
# fmt: off
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/trailing_semicolon.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/trailing_semicolon.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
def f():
|
def f():
|
||||||
# fmt: off
|
# fmt: off
|
||||||
a = 10
|
a = 10
|
||||||
|
@ -34,7 +34,7 @@ last_statement_with_semi ;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
def f():
|
def f():
|
||||||
# fmt: off
|
# fmt: off
|
||||||
a = 10
|
a = 10
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/yapf.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/yapf.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
# Get's formatted
|
# Get's formatted
|
||||||
a + b
|
a + b
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ a + b
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
# Get's formatted
|
# Get's formatted
|
||||||
a + b
|
a + b
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_skip/decorators.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_skip/decorators.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
|
|
||||||
@FormattedDecorator(a =b)
|
@FormattedDecorator(a =b)
|
||||||
# leading comment
|
# leading comment
|
||||||
|
@ -39,7 +39,7 @@ def foo(): # fmt: skip
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
@FormattedDecorator(a=b)
|
@FormattedDecorator(a=b)
|
||||||
# leading comment
|
# leading comment
|
||||||
@MyDecorator( # dangling comment
|
@MyDecorator( # dangling comment
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_skip/docstrings.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_skip/docstrings.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
def test():
|
def test():
|
||||||
# leading comment
|
# leading comment
|
||||||
""" This docstring does not
|
""" This docstring does not
|
||||||
|
@ -20,7 +20,7 @@ def test():
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
def test():
|
def test():
|
||||||
# leading comment
|
# leading comment
|
||||||
""" This docstring does not
|
""" This docstring does not
|
||||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_skip/match.py
|
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_skip/match.py
|
||||||
---
|
---
|
||||||
## Input
|
## Input
|
||||||
```py
|
```python
|
||||||
def http_error(status):
|
def http_error(status):
|
||||||
match status : # fmt: skip
|
match status : # fmt: skip
|
||||||
case 400 : # fmt: skip
|
case 400 : # fmt: skip
|
||||||
|
@ -80,7 +80,7 @@ match point:
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
```py
|
```python
|
||||||
def http_error(status):
|
def http_error(status):
|
||||||
match status : # fmt: skip
|
match status : # fmt: skip
|
||||||
case 400 : # fmt: skip
|
case 400 : # fmt: skip
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue