mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-16 01:25:22 +00:00
Enforce valid format options in spec tests (#9021)
This commit is contained in:
parent
b4a050c21d
commit
ee6548d7dd
10 changed files with 83 additions and 39 deletions
|
@ -22,10 +22,9 @@ def g():
|
|||
# hi
|
||||
...
|
||||
|
||||
# FIXME(#8905): Uncomment, leads to unstable formatting
|
||||
# def h():
|
||||
# ...
|
||||
# # bye
|
||||
def h():
|
||||
...
|
||||
# bye
|
||||
```
|
||||
|
||||
## Black Differences
|
||||
|
@ -41,17 +40,6 @@ def g():
|
|||
class y: ... # comment
|
||||
|
||||
# whitespace doesn't matter (note the next line has a trailing space and tab)
|
||||
@@ -13,6 +12,7 @@
|
||||
# hi
|
||||
...
|
||||
|
||||
-def h():
|
||||
- ...
|
||||
- # bye
|
||||
+# FIXME(#8905): Uncomment, leads to unstable formatting
|
||||
+# def h():
|
||||
+# ...
|
||||
+# # bye
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
@ -71,10 +59,9 @@ def g():
|
|||
# hi
|
||||
...
|
||||
|
||||
# FIXME(#8905): Uncomment, leads to unstable formatting
|
||||
# def h():
|
||||
# ...
|
||||
# # bye
|
||||
def h():
|
||||
...
|
||||
# bye
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
|
|
@ -16,6 +16,15 @@ class MyClass:
|
|||
# fmt: on
|
||||
def method():
|
||||
print ( "str" )
|
||||
|
||||
@decor(
|
||||
a=1,
|
||||
# fmt: off
|
||||
b=(2, 3),
|
||||
# fmt: on
|
||||
)
|
||||
def func():
|
||||
pass
|
||||
```
|
||||
|
||||
## Black Differences
|
||||
|
@ -23,8 +32,8 @@ class MyClass:
|
|||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,12 +1,10 @@
|
||||
-# flags: --line-ranges=12-12
|
||||
@@ -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.
|
||||
|
||||
|
@ -37,6 +46,15 @@ class MyClass:
|
|||
def method():
|
||||
- print("str")
|
||||
+ print ( "str" )
|
||||
|
||||
@decor(
|
||||
a=1,
|
||||
@@ -18,4 +16,4 @@
|
||||
# fmt: on
|
||||
)
|
||||
def func():
|
||||
- pass
|
||||
+ pass
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
@ -52,12 +70,21 @@ class MyClass:
|
|||
# fmt: on
|
||||
def method():
|
||||
print ( "str" )
|
||||
|
||||
@decor(
|
||||
a=1,
|
||||
# fmt: off
|
||||
b=(2, 3),
|
||||
# fmt: on
|
||||
)
|
||||
def func():
|
||||
pass
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
```python
|
||||
# flags: --line-ranges=12-12
|
||||
# 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.
|
||||
|
||||
|
@ -69,6 +96,15 @@ class MyClass:
|
|||
# fmt: on
|
||||
def method():
|
||||
print("str")
|
||||
|
||||
@decor(
|
||||
a=1,
|
||||
# fmt: off
|
||||
b=(2, 3),
|
||||
# fmt: on
|
||||
)
|
||||
def func():
|
||||
pass
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -13,21 +13,24 @@ importA;()<<0**0#
|
|||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,6 +1,2 @@
|
||||
importA
|
||||
-(
|
||||
- ()
|
||||
- << 0
|
||||
@@ -2,5 +2,5 @@
|
||||
(
|
||||
()
|
||||
<< 0
|
||||
- ** 0
|
||||
-) #
|
||||
+() << 0**0 #
|
||||
+ **0
|
||||
) #
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```python
|
||||
importA
|
||||
() << 0**0 #
|
||||
(
|
||||
()
|
||||
<< 0
|
||||
**0
|
||||
) #
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue