Include argument expansion operator similarly to function calls.
diff --git a/setup.py b/setup.py
index c73016b..30ea250 100644
--- a/setup.py
+++ b/setup.py
@@ -14,9 +14,10 @@
# limitations under the License.
import codecs
-import unittest
-from setuptools import setup, Command
import sys
+import unittest
+
+from setuptools import setup, Command
import yapf
diff --git a/yapf/yapflib/format_decision_state.py b/yapf/yapflib/format_decision_state.py
index a4c0310..ace8294 100644
--- a/yapf/yapflib/format_decision_state.py
+++ b/yapf/yapflib/format_decision_state.py
@@ -268,20 +268,23 @@
if opening.matching_bracket.previous_token.value == ',':
return True
- if current.is_name and previous.value == ',':
+ if ((current.is_name or current.value in {'*', '**'}) and
+ previous.value == ','):
# If we have a function call within an argument list and it won't fit on
# the remaining line, but it will fit on a line by itself, then go ahead
# and split before the call.
opening = _GetOpeningBracket(current)
if (opening and opening.value == '(' and opening.previous_token and
- opening.previous_token.is_name):
+ (opening.previous_token.is_name or
+ opening.previous_token.value in {'*', '**'})):
is_func_call = False
token = current
while token:
if token.value == '(':
is_func_call = True
break
- if not token.is_name and token.value != '.':
+ if (not (token.is_name or token.value in {'*', '**'}) and
+ token.value != '.'):
break
token = token.next_token
diff --git a/yapftests/reformatter_buganizer_test.py b/yapftests/reformatter_buganizer_test.py
index 70fab37..1bdac25 100644
--- a/yapftests/reformatter_buganizer_test.py
+++ b/yapftests/reformatter_buganizer_test.py
@@ -28,6 +28,20 @@
def setUpClass(cls):
style.SetGlobalStyle(style.CreateChromiumStyle())
+ def testB36215507(self):
+ code = textwrap.dedent("""\
+ class X():
+
+ def _():
+ aaaaaaaaaaaaa._bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(
+ mmmmmmmmmmmmm, nnnnn, ooooooooo,
+ _(ppppppppppppppppppppppppppppppppppppp),
+ *(qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq),
+ **(qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq))
+ """)
+ uwlines = yapf_test_helper.ParseAndUnwrap(code)
+ self.assertCodeEqual(code, reformatter.Reformat(uwlines))
+
def testB35212469(self):
unformatted_code = textwrap.dedent("""\
def _():