@@ -72,6 +72,59 @@ New Features
7272
7373.. _whatsnew310-pep563 :
7474
75+ Parenthesized context managers
76+ ------------------------------
77+
78+ Using enclosing parentheses for continuation across multiple lines
79+ in context managers is now supported. This allows formatting a long
80+ collection of context managers in multiple lines in a similar way
81+ as it was previously possible with import statements. For instance,
82+ all these examples are now valid:
83+
84+ .. code-block :: python
85+
86+ with (CtxManager() as example):
87+ ...
88+
89+ with (
90+ CtxManager1(),
91+ CtxManager2()
92+ ):
93+ ...
94+
95+ with (CtxManager1() as example,
96+ CtxManager2()):
97+ ...
98+
99+ with (CtxManager1(),
100+ CtxManager2() as example):
101+ ...
102+
103+ with (
104+ CtxManager1() as example1,
105+ CtxManager2() as example2
106+ ):
107+ ...
108+
109+ it is also possible to use a trailing comma at the end of the
110+ enclosed group:
111+
112+ .. code-block :: python
113+
114+ with (
115+ CtxManager1() as example1,
116+ CtxManager2() as example2,
117+ CtxManager3() as example3,
118+ ):
119+ ...
120+
121+ This new syntax uses the non LL(1) capacities of the new parser.
122+ Check :pep: `617 ` for more details.
123+
124+ (Contributed by Guido van Rossum, Pablo Galindo and Lysandros Nikolaou
125+ in :issue: `12782 ` and :issue: `40334 `.)
126+
127+
75128PEP 563: Postponed Evaluation of Annotations Becomes Default
76129------------------------------------------------------------
77130
0 commit comments