]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/black/tests/data/cases/remove_with_brackets.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '882d8795c6ff65c02f2657e596391748d1b6b7f5'
[etc/vim.git] / .vim / bundle / black / tests / data / cases / remove_with_brackets.py
1 # flags: --minimum-version=3.9
2 with (open("bla.txt")):
3     pass
4
5 with (open("bla.txt")), (open("bla.txt")):
6     pass
7
8 with (open("bla.txt") as f):
9     pass
10
11 # Remove brackets within alias expression
12 with (open("bla.txt")) as f:
13     pass
14
15 # Remove brackets around one-line context managers
16 with (open("bla.txt") as f, (open("x"))):
17     pass
18
19 with ((open("bla.txt")) as f, open("x")):
20     pass
21
22 with (CtxManager1() as example1, CtxManager2() as example2):
23     ...
24
25 # Brackets remain when using magic comma
26 with (CtxManager1() as example1, CtxManager2() as example2,):
27     ...
28
29 # Brackets remain for multi-line context managers
30 with (CtxManager1() as example1, CtxManager2() as example2, CtxManager2() as example2, CtxManager2() as example2, CtxManager2() as example2):
31     ...
32
33 # Don't touch assignment expressions
34 with (y := open("./test.py")) as f:
35     pass
36
37 # Deeply nested examples
38 # N.B. Multiple brackets are only possible
39 # around the context manager itself.
40 # Only one brackets is allowed around the
41 # alias expression or comma-delimited context managers.
42 with (((open("bla.txt")))):
43     pass
44
45 with (((open("bla.txt")))), (((open("bla.txt")))):
46     pass
47
48 with (((open("bla.txt")))) as f:
49     pass
50
51 with ((((open("bla.txt")))) as f):
52     pass
53
54 with ((((CtxManager1()))) as example1, (((CtxManager2()))) as example2):
55     ...
56
57 # output
58 with open("bla.txt"):
59     pass
60
61 with open("bla.txt"), open("bla.txt"):
62     pass
63
64 with open("bla.txt") as f:
65     pass
66
67 # Remove brackets within alias expression
68 with open("bla.txt") as f:
69     pass
70
71 # Remove brackets around one-line context managers
72 with open("bla.txt") as f, open("x"):
73     pass
74
75 with open("bla.txt") as f, open("x"):
76     pass
77
78 with CtxManager1() as example1, CtxManager2() as example2:
79     ...
80
81 # Brackets remain when using magic comma
82 with (
83     CtxManager1() as example1,
84     CtxManager2() as example2,
85 ):
86     ...
87
88 # Brackets remain for multi-line context managers
89 with (
90     CtxManager1() as example1,
91     CtxManager2() as example2,
92     CtxManager2() as example2,
93     CtxManager2() as example2,
94     CtxManager2() as example2,
95 ):
96     ...
97
98 # Don't touch assignment expressions
99 with (y := open("./test.py")) as f:
100     pass
101
102 # Deeply nested examples
103 # N.B. Multiple brackets are only possible
104 # around the context manager itself.
105 # Only one brackets is allowed around the
106 # alias expression or comma-delimited context managers.
107 with open("bla.txt"):
108     pass
109
110 with open("bla.txt"), open("bla.txt"):
111     pass
112
113 with open("bla.txt") as f:
114     pass
115
116 with open("bla.txt") as f:
117     pass
118
119 with CtxManager1() as example1, CtxManager2() as example2:
120     ...