-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
473 additions
and
483 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
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,74 @@ | ||
# Test cases for call chains and optional parentheses | ||
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() | ||
) | ||
|
||
# Currently formatted wrongly (no nested call chains) | ||
raise ( | ||
Blog.objects.filter( | ||
entry__headline__contains="Lennon", | ||
).filter( | ||
entry__pub_date__year=2008, | ||
) | ||
+ Blog.objects.filter( | ||
entry__headline__contains="Lennon", | ||
) | ||
.filter( | ||
entry__pub_date__year=2008, | ||
) | ||
.filter( | ||
entry__pub_date__year=2008, | ||
) | ||
).a() | ||
|
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.