Format AsyncFor (#5808)

This commit is contained in:
Luc Khai Hai 2023-07-17 17:38:59 +09:00 committed by GitHub
parent f5f8eb31ed
commit fb336898a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 110 additions and 146 deletions

View file

@ -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)
```

View file

@ -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: