From 5192ed484bdbe507a8dd03dc31f93e4efec95b19 Mon Sep 17 00:00:00 2001 From: Zsolt Dollenstein Date: Tue, 17 Apr 2018 09:04:35 +0100 Subject: [PATCH] Parse complex expressions in parameters after * and ** --- black.py | 2 +- blib2to3/Grammar.txt | 4 ++-- blib2to3/Grammar3.6.5.final.0.pickle | Bin 15152 -> 15143 bytes tests/expression.diff | 11 ++++++++--- tests/expression.py | 6 ++++++ 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/black.py b/black.py index c3610c7..7c487f6 100644 --- a/black.py +++ b/black.py @@ -1364,7 +1364,7 @@ def whitespace(leaf: Leaf) -> str: # noqa C901 if not prevp or prevp.type == token.LPAR: return NO - elif prev.type == token.EQUAL or prev.type == token.DOUBLESTAR: + elif prev.type in {token.EQUAL, token.STAR, token.DOUBLESTAR}: return NO elif p.type == syms.decorator: diff --git a/blib2to3/Grammar.txt b/blib2to3/Grammar.txt index 4905c91..c9cb3a7 100644 --- a/blib2to3/Grammar.txt +++ b/blib2to3/Grammar.txt @@ -138,8 +138,8 @@ arglist: argument (',' argument)* [','] # that precede iterable unpackings are blocked; etc. argument: ( test [comp_for] | test '=' test | - '**' expr | - star_expr ) + '**' test | + '*' test ) comp_iter: comp_for | comp_if comp_for: [ASYNC] 'for' exprlist 'in' or_test [comp_iter] diff --git a/blib2to3/Grammar3.6.5.final.0.pickle b/blib2to3/Grammar3.6.5.final.0.pickle index 3a8d93d064336eeef658656eb2916ca35a9089ca..e9d5fabf717b9731ad6cd3524b4d09419a08cd78 100644 GIT binary patch delta 3404 zcmZuzdu*Fm70+?L)Q>n1zmnKV>^f;;H));6@~E38EnT|N-llmpZI|WgCQjnhq#3c> zt!!OZ9+f6O2~F1%5&~8b5)U!x6aj*N7*Y`uNNfX%A*P`+1_kk~1{z}&IOpEaS)%cW z&-w1}oclZXJihDi=H)M4Hl8w`t$V@vuA{j`!1cViPsui6yPi)^=S7<+zMfA_=i{PX z8M>s$AF_#V>2%IRj~opLJWXs+F1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