Fix the input for black's line ranges test file (#9622)

This commit is contained in:
Micha Reiser 2024-01-23 11:40:23 +01:00 committed by GitHub
parent 47b8a897e7
commit 395bf3dc98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 49 additions and 106 deletions

View file

@ -5,6 +5,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/lin
## Input
```python
# flags: --line-ranges=5-6
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
def foo1(parameter_1, parameter_2, parameter_3, parameter_4, parameter_5, parameter_6, parameter_7): pass
@ -52,8 +53,8 @@ async def test_async_unformatted( ): # Trailing comment with extra leading
```diff
--- Black
+++ Ruff
@@ -1,7 +1,17 @@
-# flags: --line-ranges=5-6
@@ -1,7 +1,18 @@
# flags: --line-ranges=5-6
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
-def foo1(parameter_1, parameter_2, parameter_3, parameter_4, parameter_5, parameter_6, parameter_7): pass
@ -72,7 +73,7 @@ async def test_async_unformatted( ): # Trailing comment with extra leading
def foo2(
parameter_1,
parameter_2,
@@ -26,38 +36,52 @@
@@ -26,38 +37,52 @@
pass
@ -96,7 +97,16 @@ async def test_async_unformatted( ): # Trailing comment with extra leading
- pass
+ # Incorrectly indented prefix comments.
+ pass
+
-import typing
-from typing import (
- Any ,
- )
-class MyClass( object): # Trailing comment with extra leading space.
- #NOTE: The following indentation is incorrect:
- @decor( 1 * 3 )
- def my_func( arg):
- pass
+import typing
+from typing import (
+ Any,
@ -109,16 +119,6 @@ async def test_async_unformatted( ): # Trailing comment with extra leading
+ def my_func(arg):
+ pass
-import typing
-from typing import (
- Any ,
- )
-class MyClass( object): # Trailing comment with extra leading space.
- #NOTE: The following indentation is incorrect:
- @decor( 1 * 3 )
- def my_func( arg):
- pass
-try: # Trailing comment with extra leading space.
- for i in range(10): # Trailing comment with extra leading space.
- while condition:
@ -128,6 +128,7 @@ async def test_async_unformatted( ): # Trailing comment with extra leading
- then_something_else( )
-except ValueError as e:
- unformatted( )
+
+try: # Trailing comment with extra leading space.
+ for i in range(10): # Trailing comment with extra leading space.
+ while condition:
@ -157,6 +158,7 @@ async def test_async_unformatted( ): # Trailing comment with extra leading
## Ruff Output
```python
# flags: --line-ranges=5-6
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
def foo1(

View file

@ -5,6 +5,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/lin
## Input
```python
# flags: --line-ranges=10-11
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
@ -24,12 +25,7 @@ print ( "format me" )
```diff
--- Black
+++ Ruff
@@ -1,4 +1,3 @@
-# flags: --line-ranges=10-11
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
@@ -6,8 +5,8 @@
@@ -6,7 +6,8 @@
# This can be fixed in the future if we use a better diffing algorithm, or make Black
# perform formatting in a single pass.
@ -44,6 +40,7 @@ print ( "format me" )
## Ruff Output
```python
# flags: --line-ranges=10-11
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.

View file

@ -5,6 +5,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/lin
## Input
```python
# flags: --line-ranges=7-7 --line-ranges=17-23
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
@ -34,12 +35,7 @@ def myfunc( ): # This will be reformatted.
```diff
--- Black
+++ Ruff
@@ -1,4 +1,3 @@
-# flags: --line-ranges=7-7 --line-ranges=17-23
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
@@ -9,8 +8,10 @@
@@ -9,8 +9,10 @@
# fmt: on
@ -57,6 +53,7 @@ def myfunc( ): # This will be reformatted.
## Ruff Output
```python
# flags: --line-ranges=7-7 --line-ranges=17-23
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.

View file

@ -5,6 +5,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/lin
## Input
```python
# flags: --line-ranges=12-12 --line-ranges=21-21
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
@ -32,10 +33,7 @@ class MyClass:
```diff
--- Black
+++ Ruff
@@ -1,15 +1,13 @@
-# flags: --line-ranges=12-12 --line-ranges=21-21
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
@@ -4,12 +4,11 @@
# Regression test for an edge case involving decorators and fmt: off/on.
class MyClass:
@ -49,7 +47,7 @@ class MyClass:
@decor(
a=1,
@@ -18,4 +16,4 @@
@@ -18,4 +17,4 @@
# fmt: on
)
def func():
@ -60,6 +58,7 @@ class MyClass:
## Ruff Output
```python
# flags: --line-ranges=12-12 --line-ranges=21-21
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.

View file

@ -5,6 +5,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/lin
## Input
```python
# flags: --line-ranges=11-17
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
@ -28,9 +29,7 @@ def myfunc( ): # This will be reformatted.
```diff
--- Black
+++ Ruff
@@ -1,10 +1,11 @@
-# flags: --line-ranges=11-17
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
@@ -3,8 +3,10 @@
# flag above as it's formatting specifically these lines.
@ -48,6 +47,7 @@ def myfunc( ): # This will be reformatted.
## Ruff Output
```python
# flags: --line-ranges=11-17
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.

View file

@ -5,6 +5,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/lin
## Input
```python
# flags: --line-ranges=5-5
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
if cond1:
@ -23,12 +24,7 @@ if another_cond:
```diff
--- Black
+++ Ruff
@@ -1,4 +1,3 @@
-# flags: --line-ranges=5-5
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
if cond1:
@@ -9,4 +8,4 @@
@@ -9,4 +9,4 @@
print("else")
if another_cond:
@ -39,6 +35,7 @@ if another_cond:
## Ruff Output
```python
# flags: --line-ranges=5-5
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
if cond1:

View file

@ -5,6 +5,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/lin
## Input
```python
# flags: --line-ranges=9-11
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
@ -24,12 +25,7 @@ def restrict_to_this_line(arg1,
```diff
--- Black
+++ Ruff
@@ -1,4 +1,3 @@
-# flags: --line-ranges=9-11
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
@@ -7,5 +6,7 @@
@@ -7,5 +7,7 @@
def restrict_to_this_line(arg1, arg2, arg3):
@ -44,6 +40,7 @@ def restrict_to_this_line(arg1,
## Ruff Output
```python
# flags: --line-ranges=9-11
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.

View file

@ -1,60 +0,0 @@
---
source: crates/ruff_python_formatter/tests/fixtures.rs
input_file: crates/ruff_python_formatter/resources/test/fixtures/black/cases/line_ranges_unwrapping.py
---
## Input
```python
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
alist = [
1, 2
]
adict = {
"key" : "value"
}
func_call (
arg = value
)
```
## Black Differences
```diff
--- Black
+++ Ruff
@@ -1,4 +1,3 @@
-# flags: --line-ranges=5-5 --line-ranges=9-9 --line-ranges=13-13
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
alist = [1, 2]
```
## Ruff Output
```python
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
alist = [1, 2]
adict = {"key": "value"}
func_call(arg=value)
```
## Black Output
```python
# flags: --line-ranges=5-5 --line-ranges=9-9 --line-ranges=13-13
# NOTE: If you need to modify this file, pay special attention to the --line-ranges=
# flag above as it's formatting specifically these lines.
alist = [1, 2]
adict = {"key": "value"}
func_call(arg=value)
```