-
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.
Call chain formatting in fluent style
- Loading branch information
Showing
13 changed files
with
590 additions
and
510 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
crates/ruff_python_formatter/resources/test/fixtures/ruff/call_chains.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,82 @@ | ||
# Test cases for call chains and optional parentheses, with and without fluent style | ||
|
||
raise OsError("") from a.aaaaa( | ||
aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa | ||
).a(aaaa) | ||
|
||
raise OsError( | ||
"sökdjffffsldkfjlhsakfjhalsökafhsöfdahsödfjösaaksjdllllllllllllll" | ||
) from a.aaaaa( | ||
aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa | ||
).a( | ||
aaaa | ||
) | ||
|
||
blogs1 = Blog.objects.filter(entry__headline__contains="Lennon").filter( | ||
entry__pub_date__year=2008 | ||
) | ||
|
||
blogs2 = Blog.objects.filter( | ||
entry__headline__contains="Lennon", | ||
).filter( | ||
entry__pub_date__year=2008, | ||
) | ||
|
||
raise OsError("") from ( | ||
Blog.objects.filter( | ||
entry__headline__contains="Lennon", | ||
) | ||
.filter( | ||
entry__pub_date__year=2008, | ||
) | ||
.filter( | ||
entry__pub_date__year=2008, | ||
) | ||
) | ||
|
||
raise OsError("sökdjffffsldkfjlhsakfjhalsökafhsöfdahsödfjösaaksjdllllllllllllll") from ( | ||
Blog.objects.filter( | ||
entry__headline__contains="Lennon", | ||
) | ||
.filter( | ||
entry__pub_date__year=2008, | ||
) | ||
.filter( | ||
entry__pub_date__year=2008, | ||
) | ||
) | ||
|
||
# Break only after calls and indexing | ||
result = ( | ||
session.query(models.Customer.id) | ||
.filter( | ||
models.Customer.account_id == account_id, models.Customer.email == email_address | ||
) | ||
.count() | ||
) | ||
|
||
raise ( | ||
Blog.objects.filter( | ||
entry__headline__contains="Lennon", | ||
) | ||
.limit_results[:10] | ||
.filter( | ||
entry__pub_date__month=10, | ||
) | ||
) | ||
|
||
# Nested call chains | ||
blogs = ( | ||
Blog.objects.filter( | ||
entry__headline__contains="Lennon", | ||
).filter( | ||
entry__pub_date__year=2008, | ||
) | ||
+ Blog.objects.filter( | ||
entry__headline__contains="McCartney", | ||
) | ||
.limit_results[:10] | ||
.filter( | ||
entry__pub_date__year=2010, | ||
) | ||
).all() |
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.