mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-01 20:31:57 +00:00
Format AsyncFor (#5808)
This commit is contained in:
parent
f5f8eb31ed
commit
fb336898a5
4 changed files with 110 additions and 146 deletions
|
|
@ -1,123 +0,0 @@
|
|||
---
|
||||
source: crates/ruff_python_formatter/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_formatter/resources/test/fixtures/black/py_310/starred_for_target.py
|
||||
---
|
||||
## Input
|
||||
|
||||
```py
|
||||
for x in *a, *b:
|
||||
print(x)
|
||||
|
||||
for x in a, b, *c:
|
||||
print(x)
|
||||
|
||||
for x in *a, b, c:
|
||||
print(x)
|
||||
|
||||
for x in *a, b, *c:
|
||||
print(x)
|
||||
|
||||
async for x in *a, *b:
|
||||
print(x)
|
||||
|
||||
async for x in *a, b, *c:
|
||||
print(x)
|
||||
|
||||
async for x in a, b, *c:
|
||||
print(x)
|
||||
|
||||
async for x in (
|
||||
*loooooooooooooooooooooong,
|
||||
very,
|
||||
*loooooooooooooooooooooooooooooooooooooooooooooooong,
|
||||
):
|
||||
print(x)
|
||||
```
|
||||
|
||||
## Black Differences
|
||||
|
||||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -10,18 +10,10 @@
|
||||
for x in *a, b, *c:
|
||||
print(x)
|
||||
|
||||
-async for x in *a, *b:
|
||||
- print(x)
|
||||
+NOT_YET_IMPLEMENTED_StmtAsyncFor
|
||||
|
||||
-async for x in *a, b, *c:
|
||||
- print(x)
|
||||
+NOT_YET_IMPLEMENTED_StmtAsyncFor
|
||||
|
||||
-async for x in a, b, *c:
|
||||
- print(x)
|
||||
+NOT_YET_IMPLEMENTED_StmtAsyncFor
|
||||
|
||||
-async for x in (
|
||||
- *loooooooooooooooooooooong,
|
||||
- very,
|
||||
- *loooooooooooooooooooooooooooooooooooooooooooooooong,
|
||||
-):
|
||||
- print(x)
|
||||
+NOT_YET_IMPLEMENTED_StmtAsyncFor
|
||||
```
|
||||
|
||||
## Ruff Output
|
||||
|
||||
```py
|
||||
for x in *a, *b:
|
||||
print(x)
|
||||
|
||||
for x in a, b, *c:
|
||||
print(x)
|
||||
|
||||
for x in *a, b, c:
|
||||
print(x)
|
||||
|
||||
for x in *a, b, *c:
|
||||
print(x)
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtAsyncFor
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtAsyncFor
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtAsyncFor
|
||||
|
||||
NOT_YET_IMPLEMENTED_StmtAsyncFor
|
||||
```
|
||||
|
||||
## Black Output
|
||||
|
||||
```py
|
||||
for x in *a, *b:
|
||||
print(x)
|
||||
|
||||
for x in a, b, *c:
|
||||
print(x)
|
||||
|
||||
for x in *a, b, c:
|
||||
print(x)
|
||||
|
||||
for x in *a, b, *c:
|
||||
print(x)
|
||||
|
||||
async for x in *a, *b:
|
||||
print(x)
|
||||
|
||||
async for x in *a, b, *c:
|
||||
print(x)
|
||||
|
||||
async for x in a, b, *c:
|
||||
print(x)
|
||||
|
||||
async for x in (
|
||||
*loooooooooooooooooooooong,
|
||||
very,
|
||||
*loooooooooooooooooooooooooooooooooooooooooooooooong,
|
||||
):
|
||||
print(x)
|
||||
```
|
||||
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ async def test_async_with():
|
|||
```diff
|
||||
--- Black
|
||||
+++ Ruff
|
||||
@@ -1,62 +1,62 @@
|
||||
@@ -1,62 +1,63 @@
|
||||
# Make sure a leading comment is not removed.
|
||||
-def some_func( unformatted, args ): # fmt: skip
|
||||
+def some_func(unformatted, args): # fmt: skip
|
||||
|
|
@ -129,8 +129,8 @@ async def test_async_with():
|
|||
|
||||
async def test_async_for():
|
||||
- async for i in some_async_iter( unformatted, args ): # fmt: skip
|
||||
- print("Do something")
|
||||
+ NOT_YET_IMPLEMENTED_StmtAsyncFor # fmt: skip
|
||||
+ async for i in some_async_iter(unformatted, args): # fmt: skip
|
||||
print("Do something")
|
||||
|
||||
|
||||
-try : # fmt: skip
|
||||
|
|
@ -203,7 +203,8 @@ for i in some_iter(unformatted, args): # fmt: skip
|
|||
|
||||
|
||||
async def test_async_for():
|
||||
NOT_YET_IMPLEMENTED_StmtAsyncFor # fmt: skip
|
||||
async for i in some_async_iter(unformatted, args): # fmt: skip
|
||||
print("Do something")
|
||||
|
||||
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue