-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Micha Reiser <micha@reiser.io>
- Loading branch information
1 parent
4cfa355
commit c616650
Showing
14 changed files
with
876 additions
and
7 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
crates/ruff_linter/resources/test/fixtures/ruff/RUF047_for.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
### Errors | ||
|
||
for _ in range(0): | ||
loop_body_is_not_checked() | ||
break | ||
else: | ||
pass | ||
|
||
|
||
for this in comment: | ||
belongs_to() # `for` | ||
else: | ||
... | ||
|
||
|
||
for of in course(): | ||
this() | ||
else: | ||
... | ||
# this comment does not belong to the else | ||
|
||
|
||
### No errors | ||
|
||
for this in second_comment: | ||
belongs() # to | ||
# `else` | ||
else: | ||
pass | ||
|
||
|
||
for _and in so: | ||
does() | ||
# this | ||
else: | ||
pass | ||
|
||
|
||
for of in course(): | ||
this() | ||
else: | ||
... # too | ||
|
||
|
||
for of in course(): | ||
this() | ||
else: | ||
... | ||
# too |
84 changes: 84 additions & 0 deletions
84
crates/ruff_linter/resources/test/fixtures/ruff/RUF047_if.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
### Errors | ||
|
||
if False: | ||
condition_is_not_evaluated() | ||
else: | ||
pass | ||
|
||
|
||
if this_comment(): | ||
belongs_to() # `if` | ||
else: | ||
... | ||
|
||
|
||
if elif_is(): | ||
treated() | ||
elif the_same(): | ||
as_if() | ||
else: | ||
pass | ||
|
||
|
||
if this_second_comment(): | ||
belongs() # to | ||
# `if` | ||
else: | ||
pass | ||
|
||
if this_second_comment(): | ||
belongs() # to | ||
# `if` | ||
else: | ||
pass | ||
|
||
|
||
if of_course(): | ||
this() | ||
else: | ||
... | ||
# this comment doesn't belong to the if | ||
|
||
|
||
if of_course: this() | ||
else: ... | ||
|
||
|
||
if of_course: | ||
this() # comment | ||
else: ... | ||
|
||
|
||
def nested(): | ||
if a: | ||
b() | ||
else: | ||
... | ||
|
||
|
||
### No errors | ||
|
||
|
||
if this_second_comment(): | ||
belongs() # to | ||
# `else` | ||
else: | ||
pass | ||
|
||
|
||
if of_course(): | ||
this() | ||
else: | ||
... # too | ||
|
||
|
||
if of_course(): | ||
this() | ||
else: | ||
... | ||
# comment | ||
|
||
|
||
if of_course: | ||
this() # comment | ||
else: ... # trailing |
76 changes: 76 additions & 0 deletions
76
crates/ruff_linter/resources/test/fixtures/ruff/RUF047_try.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
### Errors | ||
|
||
try: | ||
raise try_body_is_not_checked() | ||
except: | ||
pass | ||
else: | ||
pass | ||
|
||
|
||
try: | ||
this() | ||
except comment: | ||
belongs() | ||
except: | ||
to() # `except` | ||
else: | ||
... | ||
|
||
|
||
try: | ||
of_course() | ||
except: | ||
this() | ||
else: | ||
... | ||
# This comment belongs to finally | ||
finally: | ||
pass | ||
|
||
|
||
try: | ||
of_course() | ||
except: | ||
this() | ||
else: | ||
... | ||
# This comment belongs to the statement coming after the else | ||
|
||
|
||
### No errors | ||
|
||
try: | ||
this() | ||
except (second, comment): | ||
belongs() # to | ||
# `else` | ||
else: | ||
pass | ||
|
||
|
||
try: | ||
and_so() | ||
except: | ||
does() | ||
# this | ||
else: | ||
... | ||
|
||
|
||
try: | ||
of_course() | ||
except: | ||
this() | ||
else: | ||
... # too | ||
|
||
try: | ||
of_course() | ||
except: | ||
this() | ||
else: | ||
... | ||
# This comment belongs to else | ||
finally: | ||
pass |
49 changes: 49 additions & 0 deletions
49
crates/ruff_linter/resources/test/fixtures/ruff/RUF047_while.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
### No errors | ||
|
||
while True: | ||
loop_body_is_not_checked() | ||
break | ||
else: | ||
pass | ||
|
||
|
||
while this_comment: | ||
belongs_to() # `for` | ||
else: | ||
... | ||
|
||
|
||
while of_course(): | ||
this() | ||
else: | ||
... | ||
# this comment belongs to the statement coming after the else | ||
|
||
|
||
### No errors | ||
|
||
while this_second_comment: | ||
belongs() # to | ||
# `else` | ||
else: | ||
pass | ||
|
||
|
||
while and_so: | ||
does() | ||
# this | ||
else: | ||
... | ||
|
||
|
||
while of_course(): | ||
this() | ||
else: | ||
... # too | ||
|
||
while of_course(): | ||
this() | ||
else: | ||
... | ||
# this comment belongs to the else | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.