Support PEP 572 in while statements (#1028)

Commit d8fa8df052 added support for
parsing and formatting PEP572, but it missed the posibility to add
PEP572 syntax in while statements.
This commit is contained in:
Pablo Galindo 2019-09-18 12:54:40 +01:00 committed by Zsolt Dollenstein
parent 0c44220e21
commit 673327449f
2 changed files with 4 additions and 1 deletions

View File

@ -108,7 +108,7 @@ assert_stmt: 'assert' test [',' test]
compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated | async_stmt
async_stmt: ASYNC (funcdef | with_stmt | for_stmt)
if_stmt: 'if' namedexpr_test ':' suite ('elif' namedexpr_test ':' suite)* ['else' ':' suite]
while_stmt: 'while' test ':' suite ['else' ':' suite]
while_stmt: 'while' namedexpr_test ':' suite ['else' ':' suite]
for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]
try_stmt: ('try' ':' suite
((except_clause ':' suite)+

View File

@ -38,3 +38,6 @@ def foo(answer: (p := 42) = 5):
foo(b := 2, a=1)
foo((b := 2), a=1)
foo(c=(b := 2), a=1)
while x:= f(x):
pass