-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Format function and class definitions into a single line if its body is an ellipsis #6592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
872409a
Single-line definition if body is an ellipsis
tjkuson 70c0053
Add comments
tjkuson 71cc6d3
Handle comments
tjkuson feb4ea1
Implement clause_body
tjkuson 09d6bd7
Check for comments
tjkuson 839f2a6
Add extra tests
tjkuson f341b55
Merge main
tjkuson ebea2a9
Add troublesome test
tjkuson 9d8b832
Check for leading comments
tjkuson 4e5ef07
Support most compound statements
tjkuson c2098c6
Add snapshot
tjkuson 68fe3f1
Expand tests
tjkuson 69f323a
Collapse elif and else branches
tjkuson 852099d
Collapse case branches
tjkuson 880920c
Collapse try-except blocks
tjkuson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
102 changes: 102 additions & 0 deletions
102
crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/ellipsis.pyi
This file contains hidden or 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,102 @@ | ||
"""Compound statements with no body should be written on one line.""" | ||
|
||
if True: | ||
... | ||
elif True: | ||
... | ||
else: | ||
... | ||
|
||
if True: | ||
# comment | ||
... | ||
elif True: | ||
# comment | ||
... | ||
else: | ||
# comment | ||
... | ||
|
||
if True: | ||
... # comment | ||
elif True: | ||
... # comment | ||
else: | ||
... # comment | ||
|
||
for i in []: | ||
... | ||
else: | ||
... | ||
|
||
for i in []: | ||
# comment | ||
... | ||
else: | ||
# comment | ||
... | ||
|
||
for i in []: | ||
... # comment | ||
else: | ||
... # comment | ||
|
||
while True: | ||
... | ||
else: | ||
... | ||
|
||
while True: | ||
# comment | ||
... | ||
else: | ||
# comment | ||
... | ||
|
||
while True: | ||
... # comment | ||
else: | ||
... # comment | ||
|
||
with True: | ||
... | ||
|
||
with True: | ||
# comment | ||
... | ||
|
||
with True: | ||
... # comment | ||
|
||
match x: | ||
case 1: | ||
... | ||
case 2: | ||
# comment | ||
... | ||
case 3: | ||
... # comment | ||
|
||
try: | ||
... | ||
except: | ||
... | ||
finally: | ||
... | ||
|
||
try: | ||
# comment | ||
... | ||
except: | ||
# comment | ||
... | ||
finally: | ||
# comment | ||
... | ||
|
||
try: | ||
... # comment | ||
except: | ||
... # comment | ||
finally: | ||
... # comment |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.