-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from Cheukting/nested_with
- Loading branch information
Showing
6 changed files
with
260 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# test nested with statement NOT get reformatted in 3.8 or below | ||
|
||
with make_context_manager(1) as cm1: | ||
with make_context_manager(2) as cm2: | ||
pass | ||
|
||
with make_context_manager(1) as cm1, make_context_manager(2) as cm2: | ||
with make_context_manager(3) as cm3: | ||
pass | ||
|
||
with make_context_manager(1) as cm1: | ||
with make_context_manager(2) as cm2, make_context_manager(3) as cm3: | ||
pass | ||
|
||
with make_context_manager(1) as cm1, make_context_manager(2) as cm2: | ||
with make_context_manager(2) as cm2, make_context_manager(3) as cm3: | ||
pass | ||
|
||
with make_context_manager(1) as cm1: | ||
with make_context_manager(2) as cm2: | ||
with make_context_manager(3) as cm3: | ||
with make_context_manager(4) as cm4: | ||
pass | ||
|
||
================================================================================ | ||
|
||
# test nested with statement NOT get reformatted in 3.8 or below | ||
|
||
with make_context_manager(1) as cm1: | ||
with make_context_manager(2) as cm2: | ||
pass | ||
|
||
with make_context_manager(1) as cm1, make_context_manager(2) as cm2: | ||
with make_context_manager(3) as cm3: | ||
pass | ||
|
||
with make_context_manager(1) as cm1: | ||
with make_context_manager(2) as cm2, make_context_manager(3) as cm3: | ||
pass | ||
|
||
with make_context_manager(1) as cm1, make_context_manager(2) as cm2: | ||
with make_context_manager(2) as cm2, make_context_manager(3) as cm3: | ||
pass | ||
|
||
with make_context_manager(1) as cm1: | ||
with make_context_manager(2) as cm2: | ||
with make_context_manager(3) as cm3: | ||
with make_context_manager(4) as cm4: | ||
pass |
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,62 @@ | ||
# test nested with statement get reformatted in 3.9 or above | ||
|
||
with make_context_manager(1) as cm1: | ||
with make_context_manager(2) as cm2: | ||
pass | ||
# Preserve this comment | ||
|
||
with make_context_manager(1) as cm1, make_context_manager(2) as cm2: | ||
with make_context_manager(3) as cm3: | ||
pass | ||
|
||
with make_context_manager(1) as cm1: | ||
with make_context_manager(2) as cm2, make_context_manager(3) as cm3: | ||
pass | ||
|
||
with make_context_manager(1) as cm1, make_context_manager(2) as cm2: | ||
with make_context_manager(2) as cm2, make_context_manager(3) as cm3: | ||
pass | ||
|
||
with make_context_manager(1) as cm1: | ||
with make_context_manager(2) as cm2: | ||
with make_context_manager(3) as cm3: | ||
with make_context_manager(4) as cm4: | ||
pass | ||
|
||
================================================================================ | ||
|
||
# test nested with statement get reformatted in 3.9 or above | ||
|
||
with make_context_manager(1) as cm1, make_context_manager(2) as cm2: | ||
pass | ||
# Preserve this comment | ||
|
||
with ( | ||
make_context_manager(1) as cm1, | ||
make_context_manager(2) as cm2, | ||
make_context_manager(3) as cm3, | ||
): | ||
pass | ||
|
||
with ( | ||
make_context_manager(1) as cm1, | ||
make_context_manager(2) as cm2, | ||
make_context_manager(3) as cm3, | ||
): | ||
pass | ||
|
||
with ( | ||
make_context_manager(1) as cm1, | ||
make_context_manager(2) as cm2, | ||
make_context_manager(2) as cm2, | ||
make_context_manager(3) as cm3, | ||
): | ||
pass | ||
|
||
with ( | ||
make_context_manager(1) as cm1, | ||
make_context_manager(2) as cm2, | ||
make_context_manager(3) as cm3, | ||
make_context_manager(4) as cm4, | ||
): | ||
pass |
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,75 @@ | ||
with make_context_manager(1) as cm1: | ||
pass | ||
|
||
# cannot mix `async with` and `with` | ||
async with make_context_manager(1) as cm1: | ||
with make_context_manager(2) as cm2: | ||
pass | ||
|
||
with make_context_manager(1) as cm1: | ||
async with make_context_manager(2) as cm2: | ||
pass | ||
|
||
# cannot have comments inside with statement | ||
with \ | ||
make_context_manager(1) as cm1, \ | ||
# comment in with statement | ||
make_context_manager(2) as cm2 \ | ||
: | ||
with make_context_manager(3) as cm3: | ||
pass | ||
|
||
with make_context_manager(1) as cm1: | ||
# nested with | ||
with make_context_manager(2) as cm2: | ||
pass | ||
|
||
with make_context_manager( | ||
1 # nested with | ||
) as cm1: | ||
with make_context_manager(2) as cm2: | ||
pass | ||
|
||
with make_context_manager(1) as cm1: | ||
with make_context_manager(2) as cm2: | ||
pass | ||
a = "second statement blocks this refactor" | ||
|
||
================================================================================ | ||
|
||
with make_context_manager(1) as cm1: | ||
pass | ||
|
||
# cannot mix `async with` and `with` | ||
async with make_context_manager(1) as cm1: | ||
with make_context_manager(2) as cm2: | ||
pass | ||
|
||
with make_context_manager(1) as cm1: | ||
async with make_context_manager(2) as cm2: | ||
pass | ||
|
||
# cannot have comments inside with statement | ||
with \ | ||
make_context_manager(1) as cm1, \ | ||
# comment in with statement | ||
make_context_manager(2) as cm2 \ | ||
: | ||
with make_context_manager(3) as cm3: | ||
pass | ||
|
||
with make_context_manager(1) as cm1: | ||
# nested with | ||
with make_context_manager(2) as cm2: | ||
pass | ||
|
||
with make_context_manager( | ||
1 # nested with | ||
) as cm1: | ||
with make_context_manager(2) as cm2: | ||
pass | ||
|
||
with make_context_manager(1) as cm1: | ||
with make_context_manager(2) as cm2: | ||
pass | ||
a = "second statement blocks this refactor" |
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