Skip to content

Commit

Permalink
basic impl copied from StmtWhile
Browse files Browse the repository at this point in the history
  • Loading branch information
davidszotten committed Jun 17, 2023
1 parent be107da commit f1c9eb9
Show file tree
Hide file tree
Showing 14 changed files with 366 additions and 122 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
for x in y: # trailing test comment
pass # trailing last statement comment

# trailing for body comment

# leading else comment

else: # trailing else comment
pass

# trailing else body comment


for aVeryLongNameThatSpillsOverToTheNextLineBecauseItIsExtremelyLongAndGoesOnAndOnAndOnAndOnAndOnAndOnAndOnAndOnAndOn in anotherVeryLongNameThatSpillsOverToTheNextLineBecauseItIsExtremelyLongAndGoesOnAndOnAndOnAndOnAndOnAndOnAndOnAndOnAndOn: # trailing comment
pass

else:
...

for (
x,
y,
) in z: # comment
...


# remove brackets around x,y but keep them around z,w
for (x, y) in (z, w):
...


# type comment
for x in (): # type: int
...
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ lambda x=lambda y={1: 3}: y['x':lambda y: {1: 2}]: x
```diff
--- Black
+++ Ruff
@@ -1,4 +1,3 @@
@@ -1,4 +1,4 @@
-for ((x in {}) or {})["a"] in x:
- pass
+for NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key] in x:
pass
-pem_spam = lambda l, spam={"x": 3}: not spam.get(l.strip())
-lambda x=lambda y={1: 3}: y["x" : lambda y: {1: 2}]: x
+NOT_YET_IMPLEMENTED_StmtFor
+pem_spam = lambda x: True
+lambda x: True
```

## Ruff Output

```py
NOT_YET_IMPLEMENTED_StmtFor
for NOT_IMPLEMENTED_value[NOT_IMPLEMENTED_key] in x:
pass
pem_spam = lambda x: True
lambda x: True
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ if True:
```diff
--- Black
+++ Ruff
@@ -1,99 +1,52 @@
@@ -1,61 +1,36 @@
-import core, time, a
+NOT_YET_IMPLEMENTED_StmtImport
Expand Down Expand Up @@ -164,12 +164,10 @@ if True:
+NOT_YET_IMPLEMENTED_StmtAssert
# looping over a 1-tuple should also not get wrapped
-for x in (1,):
- pass
-for (x,) in (1,), (2,), (3,):
- pass
+NOT_YET_IMPLEMENTED_StmtFor
+NOT_YET_IMPLEMENTED_StmtFor
for x in (1,):
@@ -63,37 +38,17 @@
for (x,) in (1,), (2,), (3,):
pass
-[
- 1,
Expand Down Expand Up @@ -253,8 +251,10 @@ y = {NOT_IMPLEMENTED_dict_key: NOT_IMPLEMENTED_dict_value}
NOT_YET_IMPLEMENTED_StmtAssert
# looping over a 1-tuple should also not get wrapped
NOT_YET_IMPLEMENTED_StmtFor
NOT_YET_IMPLEMENTED_StmtFor
for x in (1,):
pass
for (x,) in (1,), (2,), (3,):
pass
[1, 2, 3]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def func():
```diff
--- Black
+++ Ruff
@@ -3,46 +3,15 @@
@@ -3,46 +3,17 @@
# %%
def func():
Expand Down Expand Up @@ -97,7 +97,9 @@ def func():
- )
- # This should be left alone (after)
- )
+ NOT_YET_IMPLEMENTED_StmtFor
+ for exc in exc_value.NOT_IMPLEMENTED_attr:
+ if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
+ NOT_IMPLEMENTED_call()
# everything is fine if the expression isn't nested
- traceback.TracebackException.from_exception(
Expand Down Expand Up @@ -128,7 +130,9 @@ def func():
# Capture each of the exceptions in the MultiError along with each of their causes and contexts
if NOT_IMPLEMENTED_call():
embedded = []
NOT_YET_IMPLEMENTED_StmtFor
for exc in exc_value.NOT_IMPLEMENTED_attr:
if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
NOT_IMPLEMENTED_call()
# everything is fine if the expression isn't nested
NOT_IMPLEMENTED_call()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ if __name__ == "__main__":
```diff
--- Black
+++ Ruff
@@ -1,33 +1,20 @@
@@ -1,6 +1,6 @@
while True:
- if something.changed:
- do.stuff() # trailing comment
Expand All @@ -95,38 +95,41 @@ if __name__ == "__main__":
# Comment belongs to the `if` block.
# This one belongs to the `while` block.
# Should this one, too? I guess so.
@@ -8,26 +8,20 @@
# This one is properly standalone now.
-
-for i in range(100):
- # first we do this
+for i in NOT_IMPLEMENTED_call():
# first we do this
- if i % 33 == 0:
- break
+ if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
+ NOT_YET_IMPLEMENTED_StmtBreak
- # then we do this
# then we do this
- print(i)
- # and finally we loop around
+NOT_YET_IMPLEMENTED_StmtFor
+ NOT_IMPLEMENTED_call()
# and finally we loop around
-with open(some_temp_file) as f:
- data = f.read()
-
+NOT_YET_IMPLEMENTED_StmtWith
-try:
- with open(some_other_file) as w:
- w.write(data)
+NOT_YET_IMPLEMENTED_StmtWith
+NOT_YET_IMPLEMENTED_StmtTry
-except OSError:
- print("problems")
+NOT_YET_IMPLEMENTED_StmtTry
-
-import sys
+NOT_YET_IMPLEMENTED_StmtImport
# leading function comment
@@ -42,7 +29,7 @@
@@ -42,7 +36,7 @@
# leading 1
@deco1
# leading 2
Expand All @@ -135,7 +138,7 @@ if __name__ == "__main__":
# leading 3
@deco3
def decorated1():
@@ -52,7 +39,7 @@
@@ -52,7 +46,7 @@
# leading 1
@deco1
# leading 2
Expand All @@ -144,7 +147,7 @@ if __name__ == "__main__":
# leading function comment
def decorated1():
...
@@ -69,5 +56,5 @@
@@ -69,5 +63,5 @@
...
Expand All @@ -167,7 +170,14 @@ while True:
# This one is properly standalone now.
NOT_YET_IMPLEMENTED_StmtFor
for i in NOT_IMPLEMENTED_call():
# first we do this
if NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right:
NOT_YET_IMPLEMENTED_StmtBreak
# then we do this
NOT_IMPLEMENTED_call()
# and finally we loop around
NOT_YET_IMPLEMENTED_StmtWith
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ last_call()
Name
None
True
@@ -7,294 +8,236 @@
@@ -7,264 +8,234 @@
1
1.0
1j
Expand Down Expand Up @@ -629,20 +629,23 @@ last_call()
-)
-what_is_up_with_those_new_coord_names = (coord_names | set(vars_to_create)) - set(
- vars_to_remove
-)
+e = NOT_IMPLEMENTED_call()
+f = 1, NOT_YET_IMPLEMENTED_ExprStarred
+g = 1, NOT_YET_IMPLEMENTED_ExprStarred
+what_is_up_with_those_new_coord_names = (
+ (coord_names + NOT_IMPLEMENTED_call())
+ + NOT_IMPLEMENTED_call()
)
-result = (
- session.query(models.Customer.id)
- .filter(
- models.Customer.account_id == account_id, models.Customer.email == email_address
- )
- .order_by(models.Customer.id.asc())
- .all()
+e = NOT_IMPLEMENTED_call()
+f = 1, NOT_YET_IMPLEMENTED_ExprStarred
+g = 1, NOT_YET_IMPLEMENTED_ExprStarred
+what_is_up_with_those_new_coord_names = (
+ (coord_names + NOT_IMPLEMENTED_call())
+ + NOT_IMPLEMENTED_call()
+ (coord_names | NOT_IMPLEMENTED_call())
+ - NOT_IMPLEMENTED_call()
)
-result = (
- session.query(models.Customer.id)
Expand All @@ -653,10 +656,7 @@ last_call()
- models.Customer.id.asc(),
- )
- .all()
+what_is_up_with_those_new_coord_names = (
+ (coord_names | NOT_IMPLEMENTED_call())
+ - NOT_IMPLEMENTED_call()
)
-)
-Ø = set()
-authors.łukasz.say_thanks()
-mapping = {
Expand Down Expand Up @@ -696,38 +696,36 @@ last_call()
- force=False
-), "Short message"
-assert parens is TooMany
-for (x,) in (1,), (2,), (3,):
- ...
-for y in ():
- ...
-for z in (i for i in (1, 2, 3)):
- ...
-for i in call():
- ...
-for j in 1 + (2 + 3):
- ...
-while this and that:
+NOT_IMPLEMENTED_call()
+NOT_IMPLEMENTED_call()
+NOT_IMPLEMENTED_call()
+NOT_YET_IMPLEMENTED_StmtAssert
+NOT_YET_IMPLEMENTED_StmtAssert
+NOT_YET_IMPLEMENTED_StmtAssert
+NOT_YET_IMPLEMENTED_StmtFor
+NOT_YET_IMPLEMENTED_StmtFor
+NOT_YET_IMPLEMENTED_StmtFor
+NOT_YET_IMPLEMENTED_StmtFor
+NOT_YET_IMPLEMENTED_StmtFor
for (x,) in (1,), (2,), (3,):
...
for y in ():
...
-for z in (i for i in (1, 2, 3)):
+for z in (i for i in []):
...
-for i in call():
+for i in NOT_IMPLEMENTED_call():
...
for j in 1 + (2 + 3):
...
-while this and that:
+while NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
...
-for (
- addr_family,
- addr_type,
- addr_proto,
- addr_canonname,
- addr_sockaddr,
for (
addr_family,
@@ -272,29 +243,13 @@
addr_proto,
addr_canonname,
addr_sockaddr,
-) in socket.getaddrinfo("google.com", "http"):
- pass
+) in NOT_IMPLEMENTED_call():
pass
-a = (
- aaaa.bbbb.cccc.dddd.eeee.ffff.gggg.hhhh.iiii.jjjj.kkkk.llll.mmmm.nnnn.oooo.pppp
- in qqqq.rrrr.ssss.tttt.uuuu.vvvv.xxxx.yyyy.zzzz
Expand All @@ -749,7 +747,6 @@ last_call()
- and threading.current_thread() != threading.main_thread()
- or signal.getsignal(signal.SIGINT) != signal.default_int_handler
-):
+NOT_YET_IMPLEMENTED_StmtFor
+a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
+a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
+a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
Expand All @@ -758,7 +755,7 @@ last_call()
return True
if (
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -327,24 +270,44 @@
@@ -327,24 +282,44 @@
):
return True
if (
Expand Down Expand Up @@ -815,7 +812,7 @@ last_call()
):
return True
(
@@ -363,8 +326,9 @@
@@ -363,8 +338,9 @@
bbbb >> bbbb * bbbb
(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Expand Down Expand Up @@ -1059,14 +1056,26 @@ NOT_IMPLEMENTED_call()
NOT_YET_IMPLEMENTED_StmtAssert
NOT_YET_IMPLEMENTED_StmtAssert
NOT_YET_IMPLEMENTED_StmtAssert
NOT_YET_IMPLEMENTED_StmtFor
NOT_YET_IMPLEMENTED_StmtFor
NOT_YET_IMPLEMENTED_StmtFor
NOT_YET_IMPLEMENTED_StmtFor
NOT_YET_IMPLEMENTED_StmtFor
for (x,) in (1,), (2,), (3,):
...
for y in ():
...
for z in (i for i in []):
...
for i in NOT_IMPLEMENTED_call():
...
for j in 1 + (2 + 3):
...
while NOT_IMPLEMENTED_bool_op1 and NOT_IMPLEMENTED_bool_op2:
...
NOT_YET_IMPLEMENTED_StmtFor
for (
addr_family,
addr_type,
addr_proto,
addr_canonname,
addr_sockaddr,
) in NOT_IMPLEMENTED_call():
pass
a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
a = NOT_IMPLEMENTED_left < NOT_IMPLEMENTED_right
Expand Down
Loading

0 comments on commit f1c9eb9

Please sign in to comment.