mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 05:25:17 +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
|
@ -71,7 +71,7 @@ fn black_compatibility() {
|
|||
// today.
|
||||
let mut snapshot = String::new();
|
||||
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();
|
||||
|
||||
|
@ -83,10 +83,10 @@ fn black_compatibility() {
|
|||
write!(snapshot, "{}", CodeFrame::new("diff", &diff)).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, "{}", CodeFrame::new("py", &expected_output)).unwrap();
|
||||
write!(snapshot, "{}", CodeFrame::new("python", &expected_output)).unwrap();
|
||||
|
||||
insta::with_settings!({
|
||||
omit_expression => true,
|
||||
|
@ -113,7 +113,7 @@ fn format() {
|
|||
|
||||
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");
|
||||
if let Ok(options_file) = fs::File::open(options_path) {
|
||||
|
@ -135,7 +135,7 @@ fn format() {
|
|||
"### Output {}\n{}{}",
|
||||
i + 1,
|
||||
CodeFrame::new("", &DisplayPyOptions(&options)),
|
||||
CodeFrame::new("py", &formatted_code)
|
||||
CodeFrame::new("python", &formatted_code)
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
@ -159,14 +159,19 @@ fn format() {
|
|||
);
|
||||
|
||||
if formatted == formatted_preview {
|
||||
writeln!(snapshot, "## Output\n{}", CodeFrame::new("py", &formatted)).unwrap();
|
||||
writeln!(
|
||||
snapshot,
|
||||
"## Output\n{}",
|
||||
CodeFrame::new("python", &formatted)
|
||||
)
|
||||
.unwrap();
|
||||
} else {
|
||||
// Having both snapshots makes it hard to see the difference, so we're keeping only
|
||||
// diff.
|
||||
writeln!(
|
||||
snapshot,
|
||||
"## Output\n{}\n## Preview changes\n{}",
|
||||
CodeFrame::new("py", &formatted),
|
||||
CodeFrame::new("python", &formatted),
|
||||
CodeFrame::new(
|
||||
"diff",
|
||||
TextDiff::from_lines(formatted, formatted_preview)
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/condition
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
long_kwargs_single_line = my_function(
|
||||
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,
|
||||
|
@ -149,7 +149,7 @@ def something():
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
long_kwargs_single_line = my_function(
|
||||
foo="test, this is a sample value",
|
||||
bar=some_long_value_name_foo_bar_baz
|
||||
|
@ -238,7 +238,7 @@ def something():
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
long_kwargs_single_line = my_function(
|
||||
foo="test, this is a sample value",
|
||||
bar=(
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
def abc ():
|
||||
return ["hello", "world",
|
||||
"!"]
|
||||
|
@ -33,7 +33,7 @@ print( "Incorrect formatting"
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
def abc():
|
||||
return ["hello", "world", "!"]
|
||||
|
||||
|
@ -43,7 +43,7 @@ print("Incorrect formatting")
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
def abc ():
|
||||
return ["hello", "world",
|
||||
"!"]
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
@dataclass
|
||||
class DebugVisitor(Visitor[T]):
|
||||
tree_depth: int = 0
|
||||
|
@ -79,7 +79,7 @@ class DebugVisitor(Visitor[T]):
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
@dataclass
|
||||
class DebugVisitor(Visitor[T]):
|
||||
tree_depth: int = 0
|
||||
|
@ -116,7 +116,7 @@ class DebugVisitor(Visitor[T]):
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
@dataclass
|
||||
class DebugVisitor(Visitor[T]):
|
||||
tree_depth: int = 0
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
# This file doesn't use the standard decomposition.
|
||||
# Decorator syntax test cases are separated by double # comments.
|
||||
# Those before the 'output' comment are valid under the old syntax.
|
||||
|
@ -378,7 +378,7 @@ def f():
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# This file doesn't use the standard decomposition.
|
||||
# Decorator syntax test cases are separated by double # comments.
|
||||
# Those before the 'output' comment are valid under the old syntax.
|
||||
|
@ -589,7 +589,7 @@ def f():
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
##
|
||||
|
||||
@decorator()()
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
class ALonelyClass:
|
||||
'''
|
||||
A multiline class docstring.
|
||||
|
@ -208,7 +208,7 @@ def multiline_backslash_3():
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
class ALonelyClass:
|
||||
"""
|
||||
A multiline class docstring.
|
||||
|
@ -336,7 +336,7 @@ def multiline_backslash_3():
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
class ALonelyClass:
|
||||
'''
|
||||
A multiline class docstring.
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
def do_not_touch_this_prefix():
|
||||
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
|
||||
|
||||
```py
|
||||
```python
|
||||
def do_not_touch_this_prefix():
|
||||
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
|
||||
|
||||
```py
|
||||
```python
|
||||
def do_not_touch_this_prefix():
|
||||
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
|
||||
|
||||
```py
|
||||
```python
|
||||
# flags: --pyi
|
||||
from typing import Union
|
||||
|
||||
|
@ -119,7 +119,7 @@ def eggs() -> Union[str, int]: ...
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# flags: --pyi
|
||||
from typing import Union
|
||||
|
||||
|
@ -183,7 +183,7 @@ def eggs() -> Union[str, int]:
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
from typing import Union
|
||||
|
||||
@bird
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan
|
|||
---
|
||||
## 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."
|
||||
|
@ -324,7 +324,7 @@ long_unmergable_string_with_pragma = (
|
|||
|
||||
## 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."
|
||||
|
@ -617,7 +617,7 @@ long_unmergable_string_with_pragma = (
|
|||
|
||||
## 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."
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
importA;()<<0**0#
|
||||
```
|
||||
|
||||
|
@ -25,14 +25,14 @@ importA;()<<0**0#
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
importA
|
||||
() << 0**0 #
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
importA
|
||||
(
|
||||
()
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/miscellan
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
''''''
|
||||
|
||||
'\''
|
||||
|
@ -88,7 +88,7 @@ f"\"{a}\"{'hello' * b}\"{c}\""
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
""""""
|
||||
|
||||
"'"
|
||||
|
@ -151,7 +151,7 @@ f"\"{a}\"{'hello' * b}\"{c}\""
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
""""""
|
||||
|
||||
"'"
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/py_310/pa
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
import match
|
||||
|
||||
match something:
|
||||
|
@ -162,7 +162,7 @@ match bar1:
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
import match
|
||||
|
||||
match something:
|
||||
|
@ -295,7 +295,7 @@ match bar1:
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
import match
|
||||
|
||||
match something:
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/py_310/pa
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
match something:
|
||||
case b(): print(1+1)
|
||||
case c(
|
||||
|
@ -99,7 +99,7 @@ match match(
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
match something:
|
||||
case b():
|
||||
print(1 + 1)
|
||||
|
@ -145,7 +145,7 @@ match match():
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
match something:
|
||||
case b():
|
||||
print(1 + 1)
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/py_310/pe
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
# Unparenthesized walruses are now allowed in indices since Python 3.10.
|
||||
x[a:=0]
|
||||
x[a:=0, b:=1]
|
||||
|
@ -42,7 +42,7 @@ f(x, (a := b + c for c in range(10)), y=z, **q)
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# Unparenthesized walruses are now allowed in indices since Python 3.10.
|
||||
x[a := 0]
|
||||
x[a := 0, b := 1]
|
||||
|
@ -62,7 +62,7 @@ f(x, (a := b + c for c in range(10)), y=z, **q)
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# Unparenthesized walruses are now allowed in indices since Python 3.10.
|
||||
x[a:=0]
|
||||
x[a:=0, b:=1]
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/py_38/pep
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
if (foo := 0):
|
||||
pass
|
||||
|
||||
|
@ -94,7 +94,7 @@ async def await_the_walrus():
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
if foo := 0:
|
||||
pass
|
||||
|
||||
|
@ -170,7 +170,7 @@ async def await_the_walrus():
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
if foo := 0:
|
||||
pass
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/raw_docst
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
# flags: --preview --skip-string-normalization
|
||||
class C:
|
||||
|
||||
|
@ -50,7 +50,7 @@ class UpperCaseR:
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# flags: --preview --skip-string-normalization
|
||||
class C:
|
||||
|
||||
|
@ -72,7 +72,7 @@ class UpperCaseR:
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
class C:
|
||||
r"""Raw"""
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
def bob(): \
|
||||
# pylint: disable=W9016
|
||||
pass
|
||||
|
@ -36,7 +36,7 @@ def bobtwo(): \
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
def bob():
|
||||
# pylint: disable=W9016
|
||||
pass
|
||||
|
@ -49,7 +49,7 @@ def bobtwo():
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
def bob(): # pylint: disable=W9016
|
||||
pass
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
||||
MyLovelyCompanyTeamProjectComponent # NOT DRY
|
||||
)
|
||||
|
@ -246,7 +246,7 @@ instruction()#comment with bad spacing
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
||||
MyLovelyCompanyTeamProjectComponent, # NOT DRY
|
||||
)
|
||||
|
@ -442,7 +442,7 @@ instruction() # comment with bad spacing
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import (
|
||||
MyLovelyCompanyTeamProjectComponent, # NOT DRY
|
||||
)
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
from typing import Any, Tuple
|
||||
|
||||
|
||||
|
@ -181,7 +181,7 @@ aaaaaaaaaaaaa, bbbbbbbbb = map(list, map(itertools.chain.from_iterable, zip(*ite
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
from typing import Any, Tuple
|
||||
|
||||
|
||||
|
@ -315,7 +315,7 @@ aaaaaaaaaaaaa, bbbbbbbbb = map(list, map(itertools.chain.from_iterable, zip(*ite
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
from typing import Any, Tuple
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
# Test for https://github.com/psf/black/issues/246.
|
||||
|
||||
some = statement
|
||||
|
@ -179,7 +179,7 @@ def bar():
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# Test for https://github.com/psf/black/issues/246.
|
||||
|
||||
some = statement
|
||||
|
@ -342,7 +342,7 @@ def bar():
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# Test for https://github.com/psf/black/issues/246.
|
||||
|
||||
some = statement
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
class C:
|
||||
def test(self) -> None:
|
||||
with patch("black.out", print):
|
||||
|
@ -242,7 +242,7 @@ class C:
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
class C:
|
||||
def test(self) -> None:
|
||||
with patch("black.out", print):
|
||||
|
@ -427,7 +427,7 @@ class C:
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
class C:
|
||||
def test(self) -> None:
|
||||
with patch("black.out", print):
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
class C:
|
||||
def test(self) -> None:
|
||||
with patch("black.out", print):
|
||||
|
@ -242,7 +242,7 @@ class C:
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
class C:
|
||||
def test(self) -> None:
|
||||
with patch("black.out", print):
|
||||
|
@ -427,7 +427,7 @@ class C:
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
class C:
|
||||
def test(self) -> None:
|
||||
with patch("black.out", print):
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
def docstring_almost_at_line_limit():
|
||||
"""long docstring.................................................................
|
||||
"""
|
||||
|
@ -76,7 +76,7 @@ def single_quote_docstring_over_line_limit2():
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
def docstring_almost_at_line_limit():
|
||||
"""long docstring................................................................."""
|
||||
|
||||
|
@ -130,7 +130,7 @@ def single_quote_docstring_over_line_limit2():
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
def docstring_almost_at_line_limit():
|
||||
"""long docstring................................................................."""
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
...
|
||||
'some_string'
|
||||
b'\\xa3'
|
||||
|
@ -279,7 +279,7 @@ last_call()
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
...
|
||||
"some_string"
|
||||
b"\\xa3"
|
||||
|
@ -655,7 +655,7 @@ last_call()
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
...
|
||||
"some_string"
|
||||
b"\\xa3"
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import sys
|
||||
|
@ -271,7 +271,7 @@ d={'a':1,
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import sys
|
||||
|
@ -506,7 +506,7 @@ d={'a':1,
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import sys
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
# fmt: off
|
||||
@test([
|
||||
1, 2,
|
||||
|
@ -53,7 +53,7 @@ def f(): pass
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# fmt: off
|
||||
@test([
|
||||
1, 2,
|
||||
|
@ -71,7 +71,7 @@ def f(): pass
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# fmt: off
|
||||
@test([
|
||||
1, 2,
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
# Regression test for https://github.com/psf/black/issues/3129.
|
||||
setup(
|
||||
entry_points={
|
||||
|
@ -122,7 +122,7 @@ elif unformatted:
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# Regression test for https://github.com/psf/black/issues/3129.
|
||||
setup(
|
||||
entry_points={
|
||||
|
@ -213,7 +213,7 @@ elif unformatted:
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# Regression test for https://github.com/psf/black/issues/3129.
|
||||
setup(
|
||||
entry_points={
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
# Regression test for https://github.com/psf/black/issues/3438
|
||||
|
||||
import ast
|
||||
|
@ -43,7 +43,7 @@ import zoneinfo
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# Regression test for https://github.com/psf/black/issues/3438
|
||||
|
||||
import ast
|
||||
|
@ -68,7 +68,7 @@ import zoneinfo
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# Regression test for https://github.com/psf/black/issues/3438
|
||||
|
||||
import ast
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
a, b, c = 3, 4, 5
|
||||
if (
|
||||
a == 3
|
||||
|
@ -34,7 +34,7 @@ else:
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
a, b, c = 3, 4, 5
|
||||
if (
|
||||
a == 3
|
||||
|
@ -48,7 +48,7 @@ else:
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
a, b, c = 3, 4, 5
|
||||
if (
|
||||
a == 3
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import sys
|
||||
|
@ -119,7 +119,7 @@ def __await__(): return (yield)
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import sys
|
||||
|
@ -273,7 +273,7 @@ def __await__():
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import sys
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
def f(
|
||||
a,
|
||||
**kwargs,
|
||||
|
@ -85,7 +85,7 @@ with hmm_but_this_should_get_two_preceding_newlines():
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
def f(
|
||||
a,
|
||||
**kwargs,
|
||||
|
@ -153,7 +153,7 @@ with hmm_but_this_should_get_two_preceding_newlines():
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
def f(
|
||||
a,
|
||||
**kwargs,
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
def f(): # type: ignore
|
||||
...
|
||||
|
||||
|
@ -64,7 +64,7 @@ def h():
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
def f(): # type: ignore
|
||||
...
|
||||
|
||||
|
@ -94,7 +94,7 @@ def h():
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
def f(): # type: ignore
|
||||
...
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
# This is a regression test. Issue #3737
|
||||
|
||||
a = ( # type: ignore
|
||||
|
@ -48,7 +48,7 @@ print( "111" ) # type: ignore
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# This is a regression test. Issue #3737
|
||||
|
||||
a = ( # type: ignore
|
||||
|
@ -70,7 +70,7 @@ print("111") # type: ignore
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# This is a regression test. Issue #3737
|
||||
|
||||
a = ( # type: ignore
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
import asyncio
|
||||
|
||||
# Control example
|
||||
|
@ -108,7 +108,7 @@ async def main():
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
import asyncio
|
||||
|
||||
|
||||
|
@ -208,7 +208,7 @@ async def main():
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
import asyncio
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
# These brackets are redundant, therefore remove.
|
||||
try:
|
||||
a.something
|
||||
|
@ -62,7 +62,7 @@ except (some.really.really.really.looooooooooooooooooooooooooooooooong.module.ov
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# These brackets are redundant, therefore remove.
|
||||
try:
|
||||
a.something
|
||||
|
@ -107,7 +107,7 @@ except (
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# These brackets are redundant, therefore remove.
|
||||
try:
|
||||
a.something
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
# Only remove tuple brackets after `for`
|
||||
for (k, v) in d.items():
|
||||
print(k, v)
|
||||
|
@ -46,7 +46,7 @@ for (((((k, v))))) in d.items():
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# Only remove tuple brackets after `for`
|
||||
for k, v in d.items():
|
||||
print(k, v)
|
||||
|
@ -76,7 +76,7 @@ for k, v in d.items():
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# Only remove tuple brackets after `for`
|
||||
for k, v in d.items():
|
||||
print(k, v)
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
# Control
|
||||
def double(a: int) -> int:
|
||||
return 2*a
|
||||
|
@ -126,7 +126,7 @@ def foo() -> tuple[int, int, int,]:
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# Control
|
||||
def double(a: int) -> int:
|
||||
return 2 * a
|
||||
|
@ -259,7 +259,7 @@ def foo() -> (
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# Control
|
||||
def double(a: int) -> int:
|
||||
return 2 * a
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
importA;() << 0 ** 101234234242352525425252352352525234890264906820496920680926538059059209922523523525 #
|
||||
|
||||
assert sort_by_dependency(
|
||||
|
@ -66,7 +66,7 @@ assert (
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
importA
|
||||
(
|
||||
()
|
||||
|
@ -129,7 +129,7 @@ assert a_function(
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
importA
|
||||
(
|
||||
()
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
zero(one,).two(three,).four(five,)
|
||||
|
||||
func1(arg1).func2(arg2,).func3(arg3).func4(arg4,).func5(arg5)
|
||||
|
@ -72,7 +72,7 @@ assert xxxxxxxxx.xxxxxxxxx.xxxxxxxxx(
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
zero(
|
||||
one,
|
||||
).two(
|
||||
|
@ -123,7 +123,7 @@ assert (
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
zero(
|
||||
one,
|
||||
).two(
|
||||
|
|
|
@ -4,7 +4,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/simple_ca
|
|||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
```python
|
||||
# This is a standalone comment.
|
||||
sdfjklsdfsjldkflkjsf, sdfjsdfjlksdljkfsdlkf, sdfsdjfklsdfjlksdljkf, sdsfsdfjskdflsfsdf = 1, 2, 3
|
||||
|
||||
|
@ -32,7 +32,7 @@ this_will_be_wrapped_in_parens, = struct.unpack(b"12345678901234567890")
|
|||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# This is a standalone comment.
|
||||
(
|
||||
sdfjklsdfsjldkflkjsf,
|
||||
|
@ -49,7 +49,7 @@ this_will_be_wrapped_in_parens, = struct.unpack(b"12345678901234567890")
|
|||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
```python
|
||||
# This is a standalone comment.
|
||||
(
|
||||
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
|
||||
```py
|
||||
```python
|
||||
'This string will not include \
|
||||
backslashes or newline characters.'
|
||||
|
||||
|
@ -13,7 +13,7 @@ String \"
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
"This string will not include \
|
||||
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
|
||||
```py
|
||||
```python
|
||||
def single_line_backslashes1():
|
||||
""" content\ """
|
||||
return
|
||||
|
@ -169,7 +169,7 @@ magic-trailing-comma = Respect
|
|||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
```python
|
||||
def single_line_backslashes1():
|
||||
"""content\ """
|
||||
return
|
||||
|
@ -335,7 +335,7 @@ magic-trailing-comma = Respect
|
|||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
```python
|
||||
def single_line_backslashes1():
|
||||
"""content\ """
|
||||
return
|
||||
|
@ -501,7 +501,7 @@ magic-trailing-comma = Respect
|
|||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
```python
|
||||
def single_line_backslashes1():
|
||||
"""content\ """
|
||||
return
|
||||
|
@ -667,7 +667,7 @@ magic-trailing-comma = Respect
|
|||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
```python
|
||||
def single_line_backslashes1():
|
||||
"""content\ """
|
||||
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
|
||||
```py
|
||||
```python
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
## 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
|
||||
```py
|
||||
```python
|
||||
```
|
||||
|
||||
## 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
|
||||
```py
|
||||
```python
|
||||
|
||||
```
|
||||
|
||||
## 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
|
||||
```py
|
||||
```python
|
||||
```
|
||||
|
||||
## 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
|
||||
```py
|
||||
```python
|
||||
a: string
|
||||
|
||||
b: string = "test"
|
||||
|
@ -20,7 +20,7 @@ b: list[
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
a: string
|
||||
|
||||
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
|
||||
```py
|
||||
```python
|
||||
from argparse import Namespace
|
||||
|
||||
a = Namespace()
|
||||
|
@ -161,7 +161,7 @@ result = (
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
from argparse import 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
|
||||
```py
|
||||
```python
|
||||
# Regression test for: https://github.com/astral-sh/ruff/issues/7420
|
||||
result = await self.request(
|
||||
f"/applications/{int(application_id)}/guilds/{int(scope)}/commands/{int(command_id)}/permissions"
|
||||
|
@ -57,7 +57,7 @@ await (
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
# Regression test for: https://github.com/astral-sh/ruff/issues/7420
|
||||
result = await self.request(
|
||||
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
|
||||
```py
|
||||
```python
|
||||
(aaaaaaaa
|
||||
+ # trailing operator comment
|
||||
b # trailing right comment
|
||||
|
@ -415,7 +415,7 @@ if True:
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
(
|
||||
aaaaaaaa
|
||||
+ # 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
|
||||
```py
|
||||
```python
|
||||
|
||||
raise ImproperlyConfigured(
|
||||
"The app module %r has multiple filesystem locations (%r); "
|
||||
|
@ -198,7 +198,7 @@ class EC2REPATH:
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
raise ImproperlyConfigured(
|
||||
"The app module %r has multiple filesystem locations (%r); "
|
||||
"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
|
||||
```py
|
||||
```python
|
||||
# No spacing
|
||||
5 ** 5
|
||||
5.0 ** 5.0
|
||||
|
@ -17,7 +17,7 @@ None ** None
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
# No spacing
|
||||
5**5
|
||||
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
|
||||
```py
|
||||
```python
|
||||
if (
|
||||
self._proc
|
||||
# has the child process finished?
|
||||
|
@ -194,7 +194,7 @@ if (self._proc
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
if (
|
||||
self._proc
|
||||
# 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
|
||||
```py
|
||||
```python
|
||||
b"' test"
|
||||
b'" test'
|
||||
|
||||
|
@ -137,7 +137,7 @@ magic-trailing-comma = Respect
|
|||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
```python
|
||||
b"' test"
|
||||
b'" test'
|
||||
|
||||
|
@ -286,7 +286,7 @@ magic-trailing-comma = Respect
|
|||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
```python
|
||||
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
|
||||
```py
|
||||
```python
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
|
||||
|
@ -282,7 +282,7 @@ result = (object[complicate_caller])("argument").a["b"].test(argument)
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
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
|
||||
```py
|
||||
```python
|
||||
a == b
|
||||
a != b
|
||||
a < b
|
||||
|
@ -187,7 +187,7 @@ c = (a *
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
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
|
||||
```py
|
||||
```python
|
||||
# before
|
||||
{ # open
|
||||
key# key
|
||||
|
@ -141,7 +141,7 @@ query = {
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
# before
|
||||
{ # open
|
||||
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
|
||||
```py
|
||||
```python
|
||||
{i: i for i in []}
|
||||
|
||||
{i: i for i in [1,]}
|
||||
|
@ -186,7 +186,7 @@ query = {
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
{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
|
||||
```py
|
||||
```python
|
||||
(
|
||||
f'{one}'
|
||||
f'{two}'
|
||||
|
@ -71,7 +71,7 @@ z = f'''a{""}b''' f'''c{1}d"""e'''
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
(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
|
||||
```py
|
||||
```python
|
||||
(a for b in c)
|
||||
|
||||
# parens around generator expression not required
|
||||
|
@ -78,7 +78,7 @@ tuple(
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
(a for b in c)
|
||||
|
||||
# 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
|
||||
```py
|
||||
```python
|
||||
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
|
||||
|
@ -117,7 +117,7 @@ def something():
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
a1 = 1 if True else 2
|
||||
|
||||
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
|
||||
```py
|
||||
```python
|
||||
# Leading
|
||||
lambda x: x # Trailing
|
||||
# Trailing
|
||||
|
@ -237,7 +237,7 @@ def a():
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
# Leading
|
||||
lambda x: x # 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
|
||||
```py
|
||||
```python
|
||||
# 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
|
||||
a1 = [ # a
|
||||
|
@ -67,7 +67,7 @@ c1 = [ # trailing open bracket
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
# 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
|
||||
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
|
||||
```py
|
||||
```python
|
||||
[i for i in []]
|
||||
|
||||
[i for i in [1,]]
|
||||
|
@ -114,7 +114,7 @@ aaaaaaaaaaaaaaaaaaaaa = [
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
[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
|
||||
```py
|
||||
```python
|
||||
y = 1
|
||||
|
||||
if (
|
||||
|
@ -106,7 +106,7 @@ async def f():
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
y = 1
|
||||
|
||||
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
|
||||
```py
|
||||
```python
|
||||
.1
|
||||
1.
|
||||
1E+1
|
||||
|
@ -14,7 +14,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
0.1
|
||||
1.0
|
||||
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
|
||||
```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.
|
||||
|
||||
# 88 characters unparenthesized
|
||||
|
@ -213,7 +213,7 @@ def test6():
|
|||
```
|
||||
|
||||
## 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.
|
||||
|
||||
# 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
|
||||
```py
|
||||
```python
|
||||
{i for i in []}
|
||||
|
||||
{i for i in [1,]}
|
||||
|
@ -62,7 +62,7 @@ selected_choices = {
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
{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
|
||||
```py
|
||||
```python
|
||||
# Handle comments both when lower and upper exist and when they don't
|
||||
a1 = "a"[
|
||||
# a
|
||||
|
@ -119,7 +119,7 @@ self.assertEqual(
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
# Handle comments both when lower and upper exist and when they don't
|
||||
a1 = "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
|
||||
```py
|
||||
```python
|
||||
# Expressions with empty parentheses.
|
||||
ct_match = (
|
||||
unicodedata.normalize("NFKC", s1).casefold()
|
||||
|
@ -97,7 +97,7 @@ response = await sync_to_async(
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
# Expressions with empty parentheses.
|
||||
ct_match = (
|
||||
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
|
||||
```py
|
||||
```python
|
||||
call(
|
||||
# Leading starred comment
|
||||
* # Trailing star comment
|
||||
|
@ -40,7 +40,7 @@ call(
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
call(
|
||||
# Leading starred 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
|
||||
```py
|
||||
```python
|
||||
"' test"
|
||||
'" test'
|
||||
|
||||
|
@ -152,7 +152,7 @@ magic-trailing-comma = Respect
|
|||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
```python
|
||||
"' test"
|
||||
'" test'
|
||||
|
||||
|
@ -325,7 +325,7 @@ magic-trailing-comma = Respect
|
|||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
```python
|
||||
"' 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
|
||||
```py
|
||||
```python
|
||||
# Regression test for: https://github.com/astral-sh/ruff/issues/7370
|
||||
result = (
|
||||
f(111111111111111111111111111111111111111111111111111111111111111111111111111111111)
|
||||
|
@ -12,7 +12,7 @@ result = (
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
# Regression test for: https://github.com/astral-sh/ruff/issues/7370
|
||||
result = (
|
||||
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
|
||||
```py
|
||||
```python
|
||||
# Non-wrapping parentheses checks
|
||||
a1 = 1, 2
|
||||
a2 = (1, 2)
|
||||
|
@ -78,7 +78,7 @@ i1 = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
# Non-wrapping parentheses checks
|
||||
a1 = 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
|
||||
```py
|
||||
```python
|
||||
if not aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb:
|
||||
pass
|
||||
|
||||
|
@ -202,7 +202,7 @@ def foo():
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
if (
|
||||
not aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ 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
|
||||
```py
|
||||
```python
|
||||
x = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
|
||||
x_aa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
|
@ -103,7 +103,7 @@ def f():
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
x = 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
|
||||
```py
|
||||
```python
|
||||
l = [1,2,3,4]
|
||||
|
||||
def foo():
|
||||
|
@ -128,7 +128,7 @@ print((yield x))
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
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
|
||||
```py
|
||||
```python
|
||||
l = [1,2,3,4]
|
||||
|
||||
|
||||
|
@ -42,7 +42,7 @@ def foo():
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
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
|
||||
```py
|
||||
```python
|
||||
pass
|
||||
|
||||
# fmt: off
|
||||
|
@ -35,7 +35,7 @@ def test():
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
pass
|
||||
|
||||
# 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
|
||||
```py
|
||||
```python
|
||||
# fmt: off
|
||||
|
||||
# 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
|
||||
```py
|
||||
```python
|
||||
# fmt: off
|
||||
|
||||
# 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
|
||||
```py
|
||||
```python
|
||||
def test():
|
||||
# fmt: off
|
||||
""" This docstring does not
|
||||
|
@ -36,7 +36,7 @@ magic-trailing-comma = Respect
|
|||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
```python
|
||||
def test():
|
||||
# fmt: off
|
||||
""" This docstring does not
|
||||
|
@ -69,7 +69,7 @@ magic-trailing-comma = Respect
|
|||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
```python
|
||||
def test():
|
||||
# fmt: off
|
||||
""" 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
|
||||
```py
|
||||
```python
|
||||
# Regression test for https://github.com/astral-sh/ruff/issues/8211
|
||||
|
||||
# fmt: off
|
||||
|
@ -15,7 +15,7 @@ if True:
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
# Regression test for https://github.com/astral-sh/ruff/issues/8211
|
||||
|
||||
# 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
|
||||
```py
|
||||
```python
|
||||
# Regression test for https://github.com/astral-sh/ruff/issues/8211
|
||||
|
||||
# fmt: off
|
||||
|
@ -15,7 +15,7 @@ class A:
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
# Regression test for https://github.com/astral-sh/ruff/issues/8211
|
||||
|
||||
# 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
|
||||
```py
|
||||
```python
|
||||
# fmt: off
|
||||
# DB layer (form feed at the start of the next line)
|
||||
|
||||
|
@ -14,7 +14,7 @@ def test():
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
# fmt: off
|
||||
# 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
|
||||
```py
|
||||
```python
|
||||
```
|
||||
|
||||
## Outputs
|
||||
|
@ -17,7 +17,7 @@ magic-trailing-comma = Respect
|
|||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
```python
|
||||
```
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ magic-trailing-comma = Respect
|
|||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
```python
|
||||
```
|
||||
|
||||
|
||||
|
@ -45,7 +45,7 @@ magic-trailing-comma = Respect
|
|||
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
|
||||
```py
|
||||
```python
|
||||
def test():
|
||||
# fmt: off
|
||||
|
||||
|
@ -17,7 +17,7 @@ a + b # formatted
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
def test():
|
||||
# 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
|
||||
```py
|
||||
```python
|
||||
def test():
|
||||
# fmt: off
|
||||
a_very_small_indent
|
||||
|
@ -32,7 +32,7 @@ magic-trailing-comma = Respect
|
|||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
```python
|
||||
def test():
|
||||
# fmt: off
|
||||
a_very_small_indent
|
||||
|
@ -62,7 +62,7 @@ magic-trailing-comma = Respect
|
|||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
```python
|
||||
def test():
|
||||
# fmt: off
|
||||
a_very_small_indent
|
||||
|
@ -92,7 +92,7 @@ magic-trailing-comma = Respect
|
|||
preview = Disabled
|
||||
```
|
||||
|
||||
```py
|
||||
```python
|
||||
def test():
|
||||
# fmt: off
|
||||
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
|
||||
```py
|
||||
```python
|
||||
def func():
|
||||
pass
|
||||
# fmt: off
|
||||
|
@ -43,7 +43,7 @@ def func():
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
def func():
|
||||
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
|
||||
```py
|
||||
```python
|
||||
def test():
|
||||
# fmt: off
|
||||
not formatted
|
||||
|
@ -16,7 +16,7 @@ a + b
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
def test():
|
||||
# fmt: off
|
||||
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
|
||||
```py
|
||||
```python
|
||||
# Tricky sequences of fmt off and on
|
||||
|
||||
# Formatted
|
||||
|
@ -78,7 +78,7 @@ a + b
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
# Tricky sequences of fmt off and on
|
||||
|
||||
# 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
|
||||
```py
|
||||
```python
|
||||
# Get's formatted
|
||||
a + b
|
||||
|
||||
|
@ -16,7 +16,7 @@ a + b
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
# Get's formatted
|
||||
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
|
||||
```py
|
||||
```python
|
||||
a = 10
|
||||
# fmt: off
|
||||
|
||||
|
@ -47,7 +47,7 @@ def test3 ():
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
a = 10
|
||||
# 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
|
||||
```py
|
||||
```python
|
||||
def f():
|
||||
# fmt: off
|
||||
a = 10
|
||||
|
@ -34,7 +34,7 @@ last_statement_with_semi ;
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
def f():
|
||||
# fmt: off
|
||||
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
|
||||
```py
|
||||
```python
|
||||
# Get's formatted
|
||||
a + b
|
||||
|
||||
|
@ -24,7 +24,7 @@ a + b
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
# Get's formatted
|
||||
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
|
||||
```py
|
||||
```python
|
||||
|
||||
@FormattedDecorator(a =b)
|
||||
# leading comment
|
||||
|
@ -39,7 +39,7 @@ def foo(): # fmt: skip
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
@FormattedDecorator(a=b)
|
||||
# leading 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
|
||||
```py
|
||||
```python
|
||||
def test():
|
||||
# leading comment
|
||||
""" This docstring does not
|
||||
|
@ -20,7 +20,7 @@ def test():
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
def test():
|
||||
# leading comment
|
||||
""" 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
|
||||
```py
|
||||
```python
|
||||
def http_error(status):
|
||||
match status : # fmt: skip
|
||||
case 400 : # fmt: skip
|
||||
|
@ -80,7 +80,7 @@ match point:
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
def http_error(status):
|
||||
match status : # fmt: skip
|
||||
case 400 : # fmt: skip
|
||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
|||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_skip/or_else.py
|
||||
---
|
||||
## Input
|
||||
```py
|
||||
```python
|
||||
for item in container:
|
||||
if search_something(item):
|
||||
# Found it!
|
||||
|
@ -38,7 +38,7 @@ finally : # fmt: skip
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
for item in container:
|
||||
if search_something(item):
|
||||
# Found it!
|
||||
|
|
|
@ -3,7 +3,7 @@ source: crates/ruff_python_formatter/tests/fixtures.rs
|
|||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_skip/parentheses.py
|
||||
---
|
||||
## Input
|
||||
```py
|
||||
```python
|
||||
if (
|
||||
# a leading condition comment
|
||||
len([1, 23, 3, 4, 5]) > 2 # trailing condition comment
|
||||
|
@ -27,7 +27,7 @@ if ( # trailing open parentheses comment
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
if (
|
||||
# a leading condition comment
|
||||
len([1, 23, 3, 4, 5]) > 2 # trailing condition 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/trailing_semi.py
|
||||
---
|
||||
## Input
|
||||
```py
|
||||
```python
|
||||
x = 1; # fmt: skip
|
||||
|
||||
x = 1 ; # fmt: skip
|
||||
|
@ -17,7 +17,7 @@ _; #unrelated semicolon
|
|||
```
|
||||
|
||||
## Output
|
||||
```py
|
||||
```python
|
||||
x = 1; # fmt: skip
|
||||
|
||||
x = 1 ; # 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