Split before a named assign when first arg is func call
diff --git a/CHANGELOG b/CHANGELOG
index 49096dc..293b6f8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,11 @@
# All notable changes to this project will be documented in this file.
# This project adheres to [Semantic Versioning](http://semver.org/).
+## [0.19.1] UNRELEASED
+### Changed
+- Take into account a named function argument when determining if we should
+ split before the first argument in a function call.
+
## [0.19.0] 2017-10-14
### Added
- Added `SPLIT_BEFORE_EXPRESSION_AFTER_OPENING_PAREN` that enforces a split
diff --git a/yapf/yapflib/format_decision_state.py b/yapf/yapflib/format_decision_state.py
index 60913b4..c5d84fe 100644
--- a/yapf/yapflib/format_decision_state.py
+++ b/yapf/yapflib/format_decision_state.py
@@ -773,7 +773,7 @@
if token.value == '(':
token = token.next_token
return token and token.value != ')'
- elif token.name not in {'NAME', 'DOT'}:
+ elif token.name not in {'NAME', 'DOT', 'EQUAL'}:
break
token = token.next_token
return False
diff --git a/yapftests/reformatter_buganizer_test.py b/yapftests/reformatter_buganizer_test.py
index bee5e72..9501850 100644
--- a/yapftests/reformatter_buganizer_test.py
+++ b/yapftests/reformatter_buganizer_test.py
@@ -28,6 +28,35 @@
def setUpClass(cls):
style.SetGlobalStyle(style.CreateChromiumStyle())
+ def testB34774905(self):
+ unformatted_code = """\
+x=[VarExprType(ir_name=IrName( value='x',
+expr_type=UnresolvedAttrExprType( atom=UnknownExprType(), attr_name=IrName(
+ value='x', expr_type=UnknownExprType(), usage='UNKNOWN', fqn=None,
+ astn=None), usage='REF'), usage='ATTR', fqn='<attr>.x', astn=None))]
+"""
+ expected_formatted_code = """\
+x = [
+ VarExprType(
+ ir_name=IrName(
+ value='x',
+ expr_type=UnresolvedAttrExprType(
+ atom=UnknownExprType(),
+ attr_name=IrName(
+ value='x',
+ expr_type=UnknownExprType(),
+ usage='UNKNOWN',
+ fqn=None,
+ astn=None),
+ usage='REF'),
+ usage='ATTR',
+ fqn='<attr>.x',
+ astn=None))
+]
+"""
+ uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
+ self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
+
def testB65176185(self):
code = """\
xx = zip(*[(a, b) for (a, b, c) in yy])
@@ -1315,9 +1344,10 @@
def f():
if True:
if True:
- return aaaa.bbbbbbbbb(ccccccc=dddddddddddddd({
- ('eeee', 'ffffffff'): str(j)
- }))
+ return aaaa.bbbbbbbbb(
+ ccccccc=dddddddddddddd({
+ ('eeee', 'ffffffff'): str(j)
+ }))
""")
uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))