Omit extra space in kwarg unpacking if it's an argument

Fixes #46
This commit is contained in:
Łukasz Langa 2018-03-21 18:31:58 -07:00
parent 92b377556e
commit df7aacb43e
3 changed files with 12 additions and 6 deletions

View File

@ -298,6 +298,9 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md).
* don't omit whitespace if the previous factor leaf wasn't a math
operator (#55)
* omit extra space in kwarg unpacking if it's the first argument (#46)
### 18.3a3
* don't remove single empty lines outside of bracketed expressions

View File

@ -867,21 +867,22 @@ def whitespace(leaf: Leaf) -> str: # noqa C901
if prevp.type == token.EQUAL:
if prevp.parent and prevp.parent.type in {
syms.typedargslist,
syms.varargslist,
syms.parameters,
syms.arglist,
syms.argument,
syms.parameters,
syms.typedargslist,
syms.varargslist,
}:
return NO
elif prevp.type == token.DOUBLESTAR:
if prevp.parent and prevp.parent.type in {
syms.arglist,
syms.argument,
syms.dictsetmaker,
syms.parameters,
syms.typedargslist,
syms.varargslist,
syms.parameters,
syms.arglist,
syms.dictsetmaker,
}:
return NO

View File

@ -75,6 +75,7 @@
call(arg, another, kwarg='hey', **kwargs)
call(this_is_a_very_long_variable_which_will_force_a_delimiter_split, arg, another, kwarg='hey', **kwargs) # note: no trailing comma pre-3.6
call(*gidgets[:2])
call(**self.screen_kwargs)
lukasz.langa.pl
call.me(maybe)
1 .real
@ -237,6 +238,7 @@ async def f():
**kwargs
) # note: no trailing comma pre-3.6
call(*gidgets[:2])
call(**self.screen_kwargs)
lukasz.langa.pl
call.me(maybe)
1 .real