Repository: google/yapf
Pull request #735 (2019-06-29 23:41:47)

Provide the four predefined styles when describing based_on_style
The based_on_style setting currently supports four predefined styles:

- pep8 (default)
- chromium
- google
- facebook

See: https://github.com/google/yapf/blob/master/yapf/yapflib/style.py#L445


Patch:
diff --git a/CHANGELOG b/CHANGELOG
index 4996e6b..9b49651 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,20 +2,7 @@
 # All notable changes to this project will be documented in this file.
 # This project adheres to [Semantic Versioning](http://semver.org/).
 
-## [0.28.1] UNRELEASED
-### Changed
-- Collect a parameter list into a single object. This allows us to track how a
-  parameter list is formatted, keeping state along the way. This helps when
-  supporting Python 3 type annotations.
-### Fixed
-- Format subscript lists so that splits are essentially free after a comma.
-- Don't add a space between a string and its subscript.
-- Extend discovery of '.style.yapf' & 'setup.cfg' files to search the root
-  directory as well.
-- Make sure we have parameters before we start calculating penalties for
-  splitting them.
-
-## [0.28.0] 2019-07-11
+## [0.27.1] UNRELEASED
 ### Added
 - New knob `SPLIT_ALL_TOP_LEVEL_COMMA_SEPARATED_VALUES` is a variation on
   `SPLIT_ALL_COMMA_SEPARATED_VALUES` in which, if a subexpression with a comma
@@ -23,7 +10,6 @@
   unnecessary splits).
 ### Changed
 - Set `INDENT_DICTIONARY_VALUE` for Google style.
-- Set `JOIN_MULTIPLE_LINES = False` for Google style.
 ### Fixed
 - `BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF=False` wasn't honored because the
   number of newlines was erroneously calculated beforehand.
@@ -34,8 +20,6 @@
 - Only emit unformatted if the "disable long line" is at the end of the line.
   Otherwise we could mess up formatting for containers which have them
   interspersed with code.
-- Fix a potential race condition by using the correct style for opening a file
-  which may not exist.
 
 ## [0.27.0] 2019-04-07
 ### Added
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 284b13f..62e2a5f 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -13,4 +13,3 @@ Bill Wendling <morbo@google.com>
 Eli Bendersky <eliben@google.com>
 Sam Clegg <sbc@google.com>
 Łukasz Langa <ambv@fb.com>
-Oleg Butuzov <butuzov@made.ua>
diff --git a/README.rst b/README.rst
index 995b332..6ab3132 100644
--- a/README.rst
+++ b/README.rst
@@ -168,7 +168,11 @@ with a ``[yapf]`` heading. For example:
     split_before_logical_operator = true
 
 The ``based_on_style`` setting determines which of the predefined styles this
-custom style is based on (think of it like subclassing).
+custom style is based on (think of it like subclassing). Four
+styles are predefined: ``pep8`` (default), ``chromium``, ``google`` and 
+``facebook`` (see ``_STYLE_NAME_TO_FACTORY`` in style.py_).
+
+.. _style.py: https://github.com/google/yapf/blob/master/yapf/yapflib/style.py#L445
 
 It's also possible to do the same on the command line with a dictionary. For
 example:
diff --git a/yapf/__init__.py b/yapf/__init__.py
index 73665f6..fa9c60e 100644
--- a/yapf/__init__.py
+++ b/yapf/__init__.py
@@ -40,7 +40,7 @@ from yapf.yapflib import py3compat
 from yapf.yapflib import style
 from yapf.yapflib import yapf_api
 
-__version__ = '0.28.0'
+__version__ = '0.27.0'
 
 
 def main(argv):
@@ -149,7 +149,7 @@ def main(argv):
         print('#', line and ' ' or '', line, sep='')
       option_value = style.Get(option)
       if isinstance(option_value, set) or isinstance(option_value, list):
-        option_value = ', '.join(map(str, option_value))
+        option_value = ', '.join(option_value)
       print(option.lower(), '=', option_value, sep='')
       print()
     return 0
diff --git a/yapf/yapflib/file_resources.py b/yapf/yapflib/file_resources.py
index 59c3df5..6de0b29 100644
--- a/yapf/yapflib/file_resources.py
+++ b/yapf/yapflib/file_resources.py
@@ -86,21 +86,17 @@ def GetDefaultStyleForDir(dirname, default_style=style.DEFAULT_STYLE):
 
     # See if we have a setup.cfg file with a '[yapf]' section.
     config_file = os.path.join(dirname, style.SETUP_CONFIG)
-    try:
-      fd = open(config_file)
-    except IOError:
-      pass  # It's okay if it's not there.
-    else:
-      with fd:
+    if os.path.exists(config_file):
+      with open(config_file) as fd:
         config = py3compat.ConfigParser()
         config.read_file(fd)
         if config.has_section('yapf'):
           return config_file
 
+    dirname = os.path.dirname(dirname)
     if (not dirname or not os.path.basename(dirname) or
         dirname == os.path.abspath(os.path.sep)):
       break
-    dirname = os.path.dirname(dirname)
 
   global_file = os.path.expanduser(style.GLOBAL_STYLE)
   if os.path.exists(global_file):
diff --git a/yapf/yapflib/format_decision_state.py b/yapf/yapflib/format_decision_state.py
index 3fac458..ab7a40b 100644
--- a/yapf/yapflib/format_decision_state.py
+++ b/yapf/yapflib/format_decision_state.py
@@ -48,8 +48,6 @@ class FormatDecisionState(object):
       parenthesis levels.
     comp_stack: A stack (of ComprehensionState) keeping track of properties
       applying to comprehensions.
-    param_list_stack: A stack (of ParameterListState) keeping track of
-      properties applying to function parameter lists.
     ignore_stack_for_comparison: Ignore the stack of _ParenState for state
       comparison.
   """
@@ -72,7 +70,6 @@ class FormatDecisionState(object):
     self.ignore_stack_for_comparison = False
     self.stack = [_ParenState(first_indent, first_indent)]
     self.comp_stack = []
-    self.param_list_stack = []
     self.first_indent = first_indent
     self.column_limit = style.Get('COLUMN_LIMIT')
 
@@ -89,7 +86,6 @@ class FormatDecisionState(object):
     new.first_indent = self.first_indent
     new.stack = [state.Clone() for state in self.stack]
     new.comp_stack = [state.Clone() for state in self.comp_stack]
-    new.param_list_stack = [state.Clone() for state in self.param_list_stack]
     return new
 
   def __eq__(self, other):
@@ -102,9 +98,8 @@ class FormatDecisionState(object):
             self.line.depth == other.line.depth and
             self.lowest_level_on_line == other.lowest_level_on_line and
             (self.ignore_stack_for_comparison or
-             other.ignore_stack_for_comparison or self.stack == other.stack and
-             self.comp_stack == other.comp_stack and
-             self.param_list_stack == other.param_list_stack))
+             other.ignore_stack_for_comparison or
+             self.stack == other.stack and self.comp_stack == other.comp_stack))
 
   def __ne__(self, other):
     return not self == other
@@ -564,8 +559,6 @@ class FormatDecisionState(object):
     Returns:
       The penalty of splitting after the current token.
     """
-    self._PushParameterListState(newline)
-
     penalty = 0
     if newline:
       penalty = self._AddTokenOnNewline(dry_run, must_split)
@@ -573,7 +566,6 @@ class FormatDecisionState(object):
       self._AddTokenOnCurrentLine(dry_run)
 
     penalty += self._CalculateComprehensionState(newline)
-    penalty += self._CalculateParameterListState(newline)
 
     return self.MoveStateToNextToken() + penalty
 
@@ -809,105 +801,6 @@ class FormatDecisionState(object):
 
     return penalty
 
-  def _PushParameterListState(self, newline):
-    """Push a new parameter list state for a function definition.
-
-    Args:
-      newline: Whether the current token is to be added on a newline.
-    """
-    current = self.next_token
-    previous = current.previous_token
-
-    if _IsFunctionDefinition(previous):
-      first_param_column = previous.total_length + self.stack[-2].indent
-      self.param_list_stack.append(
-          object_state.ParameterListState(previous, newline,
-                                          first_param_column))
-
-  def _CalculateParameterListState(self, newline):
-    """Makes required changes to parameter list state.
-
-    Args:
-      newline: Whether the current token is to be added on a newline.
-
-    Returns:
-      The penalty for the token-newline combination given the current
-      parameter state.
-    """
-    current = self.next_token
-    previous = current.previous_token
-    penalty = 0
-
-    if _IsFunctionDefinition(previous):
-      first_param_column = previous.total_length + self.stack[-2].indent
-      if not newline:
-        param_list = self.param_list_stack[-1]
-        if param_list.parameters and param_list.has_typed_return:
-          last_param = param_list.parameters[-1].first_token
-          last_token = _LastTokenInLine(previous.matching_bracket)
-          total_length = last_token.total_length
-          total_length -= last_param.total_length - len(last_param.value)
-          if total_length + self.column > self.column_limit:
-            # If we need to split before the trailing code of a function
-            # definition with return types, then also split before the opening
-            # parameter so that the trailing bit isn't indented on a line by
-            # itself:
-            #
-            #   def rrrrrrrrrrrrrrrrrrrrrr(ccccccccccccccccccccccc: Tuple[Text]
-            #                              ) -> List[Tuple[Text, Text]]:
-            #       pass
-            penalty += split_penalty.VERY_STRONGLY_CONNECTED
-        return penalty
-
-      if first_param_column <= self.column:
-        # Make sure we don't split after the opening bracket if the
-        # continuation indent is greater than the opening bracket:
-        #
-        #   a(
-        #       b=1,
-        #       c=2)
-        penalty += split_penalty.VERY_STRONGLY_CONNECTED
-      return penalty
-
-    if not self.param_list_stack:
-      return penalty
-
-    param_list = self.param_list_stack[-1]
-    if current == self.param_list_stack[-1].closing_bracket:
-      self.param_list_stack.pop()  # We're done with this state.
-      if newline and param_list.has_typed_return:
-        if param_list.split_before_closing_bracket:
-          penalty -= split_penalty.STRONGLY_CONNECTED
-        elif param_list.LastParamFitsOnLine(self.column):
-          penalty += split_penalty.STRONGLY_CONNECTED
-
-      if (not newline and param_list.has_typed_return and
-          param_list.has_split_before_first_param):
-        # Prefer splitting before the closing bracket if there's a return type
-        # and we've already split before the first parameter.
-        penalty += split_penalty.STRONGLY_CONNECTED
-
-      return penalty
-
-    if not param_list.parameters:
-      return penalty
-
-    if newline:
-      if self._FitsOnLine(param_list.parameters[0].first_token,
-                          _LastTokenInLine(param_list.closing_bracket)):
-        penalty += split_penalty.STRONGLY_CONNECTED
-
-    if (not newline and style.Get('SPLIT_BEFORE_NAMED_ASSIGNS') and
-        param_list.has_default_values and
-        current != param_list.parameters[0].first_token and
-        current != param_list.closing_bracket and
-        format_token.Subtype.PARAMETER_START in current.subtypes):
-      # If we want to split before parameters when there are named assigns,
-      # then add a penalty for not splitting.
-      penalty += split_penalty.STRONGLY_CONNECTED
-
-    return penalty
-
   def _GetNewlineColumn(self):
     """Return the new column on the newline."""
     current = self.next_token
@@ -948,18 +841,7 @@ class FormatDecisionState(object):
           len(self.line.first.whitespace_prefix.split('\n')[-1]) +
           style.Get('INDENT_WIDTH'))
       if token_indent == top_of_stack.indent:
-        if self.param_list_stack and _IsFunctionDef(self.line.first):
-          last_param = self.param_list_stack[-1]
-          if (last_param.LastParamFitsOnLine(token_indent) and
-              not last_param.LastParamFitsOnLine(
-                  token_indent + style.Get('CONTINUATION_INDENT_WIDTH'))):
-            self.param_list_stack[-1].split_before_closing_bracket = True
-            return token_indent
-
-          if not last_param.LastParamFitsOnLine(token_indent):
-            self.param_list_stack[-1].split_before_closing_bracket = True
-            return token_indent
-        return token_indent + style.Get('CONTINUATION_INDENT_WIDTH')
+        return top_of_stack.indent + style.Get('CONTINUATION_INDENT_WIDTH')
 
     return top_of_stack.indent
 
diff --git a/yapf/yapflib/format_token.py b/yapf/yapflib/format_token.py
index 79b2b5c..9bd2f70 100644
--- a/yapf/yapflib/format_token.py
+++ b/yapf/yapflib/format_token.py
@@ -36,30 +36,28 @@ class Subtype(object):
   NONE = 0
   UNARY_OPERATOR = 1
   BINARY_OPERATOR = 2
-  A_EXPR_OPERATOR = 3
-  M_EXPR_OPERATOR = 4
-  SUBSCRIPT_COLON = 5
-  SUBSCRIPT_BRACKET = 6
-  DEFAULT_OR_NAMED_ASSIGN = 7
-  DEFAULT_OR_NAMED_ASSIGN_ARG_LIST = 8
-  VARARGS_LIST = 9
-  VARARGS_STAR = 10
-  KWARGS_STAR_STAR = 11
-  ASSIGN_OPERATOR = 12
-  DICTIONARY_KEY = 13
-  DICTIONARY_KEY_PART = 14
-  DICTIONARY_VALUE = 15
-  DICT_SET_GENERATOR = 16
-  COMP_EXPR = 17
-  COMP_FOR = 18
-  COMP_IF = 19
-  FUNC_DEF = 20
-  DECORATOR = 21
-  TYPED_NAME = 22
-  TYPED_NAME_ARG_LIST = 23
+  A_EXPR_OPERATOR = 22
+  M_EXPR_OPERATOR = 23
+  SUBSCRIPT_COLON = 3
+  SUBSCRIPT_BRACKET = 4
+  DEFAULT_OR_NAMED_ASSIGN = 5
+  DEFAULT_OR_NAMED_ASSIGN_ARG_LIST = 6
+  VARARGS_LIST = 7
+  VARARGS_STAR = 8
+  KWARGS_STAR_STAR = 9
+  ASSIGN_OPERATOR = 10
+  DICTIONARY_KEY = 11
+  DICTIONARY_KEY_PART = 12
+  DICTIONARY_VALUE = 13
+  DICT_SET_GENERATOR = 14
+  COMP_EXPR = 21
+  COMP_FOR = 15
+  COMP_IF = 16
+  FUNC_DEF = 17
+  DECORATOR = 18
+  TYPED_NAME = 19
+  TYPED_NAME_ARG_LIST = 20
   SIMPLE_EXPRESSION = 24
-  PARAMETER_START = 25
-  PARAMETER_STOP = 26
 
 
 def _TabbedContinuationAlignPadding(spaces, align_style, tab_width,
@@ -98,8 +96,6 @@ class FormatToken(object):
       this is the first token in the unwrapped line.
     matching_bracket: If a bracket token ('[', '{', or '(') the matching
       bracket.
-    parameters: If this and its following tokens make up a parameter list, then
-      this is a list of those parameters.
     container_opening: If the object is in a container, this points to its
       opening bracket.
     container_elements: If this is the start of a container, a list of the
@@ -129,7 +125,6 @@ class FormatToken(object):
     self.next_token = None
     self.previous_token = None
     self.matching_bracket = None
-    self.parameters = []
     self.container_opening = None
     self.container_elements = []
     self.whitespace_prefix = ''
diff --git a/yapf/yapflib/object_state.py b/yapf/yapflib/object_state.py
index 124ae65..dded7c4 100644
--- a/yapf/yapflib/object_state.py
+++ b/yapf/yapflib/object_state.py
@@ -22,10 +22,6 @@ from __future__ import absolute_import
 from __future__ import division
 from __future__ import print_function
 
-from yapf.yapflib import format_token
-from yapf.yapflib import py3compat
-from yapf.yapflib import style
-
 
 class ComprehensionState(object):
   """Maintains the state of list comprehension formatting decisions.
@@ -37,9 +33,9 @@ class ComprehensionState(object):
     expr_token: The first token in the comprehension.
     for_token: The first 'for' token of the comprehension.
     has_split_at_for: Whether there is a newline immediately before the
-      for_token.
+        for_token.
     has_interior_split: Whether there is a newline within the comprehension.
-      That is, a split somewhere after expr_token or before closing_bracket.
+        That is, a split somewhere after expr_token or before closing_bracket.
   """
 
   def __init__(self, expr_token):
@@ -82,122 +78,3 @@ class ComprehensionState(object):
   def __hash__(self, *args, **kwargs):
     return hash((self.expr_token, self.for_token, self.has_split_at_for,
                  self.has_interior_split))
-
-
-class ParameterListState(object):
-  """Maintains the state of function parameter list formatting decisions.
-
-  Attributes:
-    opening_bracket: The opening bracket of the parameter list.
-    closing_bracket: The closing bracket of the parameter list.
-    has_typed_return: True if the function definition has a typed return.
-    has_default_values: True if the parameters have default values.
-    has_split_before_first_param: Whether there is a newline before the first
-      parameter.
-    opening_column: The position of the opening parameter before a newline.
-    parameters: A list of parameter objects (Parameter).
-    split_before_closing_bracket: Split before the closing bracket. Sometimes
-      needed if the indentation would collide.
-  """
-
-  def __init__(self, opening_bracket, newline, opening_column):
-    self.opening_bracket = opening_bracket
-    self.has_split_before_first_param = newline
-    self.opening_column = opening_column
-    self.parameters = opening_bracket.parameters
-    self.split_before_closing_bracket = False
-
-  @property
-  def closing_bracket(self):
-    return self.opening_bracket.matching_bracket
-
-  @property
-  def has_typed_return(self):
-    return self.closing_bracket.next_token.value == '->'
-
-  @property
-  @py3compat.lru_cache()
-  def has_default_values(self):
-    return any(param.has_default_value for param in self.parameters)
-
-  @py3compat.lru_cache()
-  def LastParamFitsOnLine(self, indent):
-    """Return true if the last parameter fits on a single line."""
-    if not self.has_typed_return:
-      return False
-    last_param = self.parameters[-1].first_token
-    last_token = self.opening_bracket.matching_bracket
-    while not last_token.is_comment and last_token.next_token:
-      last_token = last_token.next_token
-    total_length = last_token.total_length
-    total_length -= last_param.total_length - len(last_param.value)
-    return total_length + indent <= style.Get('COLUMN_LIMIT')
-
-  def Clone(self):
-    clone = ParameterListState(self.opening_bracket,
-                               self.has_split_before_first_param,
-                               self.opening_column)
-    clone.split_before_closing_bracket = self.split_before_closing_bracket
-    clone.parameters = [param.Clone() for param in self.parameters]
-    return clone
-
-  def __repr__(self):
-    return ('[opening_bracket::%s, has_split_before_first_param::%s, '
-            'opening_column::%d]' %
-            (self.opening_bracket, self.has_split_before_first_param,
-             self.opening_column))
-
-  def __eq__(self, other):
-    return hash(self) == hash(other)
-
-  def __ne__(self, other):
-    return not self == other
-
-  def __hash__(self, *args, **kwargs):
-    return hash(
-        (self.opening_bracket, self.has_split_before_first_param,
-         self.opening_column, (hash(param) for param in self.parameters)))
-
-
-class Parameter(object):
-  """A parameter in a parameter list.
-
-  Attributes:
-    first_token: (format_token.FormatToken) First token of parameter.
-    last_token: (format_token.FormatToken) Last token of parameter.
-    has_default_value: (boolean) True if the parameter has a default value
-  """
-
-  def __init__(self, first_token, last_token):
-    self.first_token = first_token
-    self.last_token = last_token
-
-  @property
-  @py3compat.lru_cache()
-  def has_default_value(self):
-    """Returns true if the parameter has a default value."""
-    tok = self.first_token
-    while tok != self.last_token:
-      if format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN in tok.subtypes:
-        return True
-      if tok.OpensScope():
-        tok = tok.matching_bracket
-      else:
-        tok = tok.next_token
-    return False
-
-  def Clone(self):
-    return Parameter(self.first_token, self.last_token)
-
-  def __repr__(self):
-    return '[first_token::%s, last_token:%s]' % (self.first_token,
-                                                 self.last_token)
-
-  def __eq__(self, other):
-    return hash(self) == hash(other)
-
-  def __ne__(self, other):
-    return not self == other
-
-  def __hash__(self, *args, **kwargs):
-    return hash((self.first_token, self.last_token))
diff --git a/yapf/yapflib/pytree_unwrapper.py b/yapf/yapflib/pytree_unwrapper.py
index f4d9cba..0d371ae 100644
--- a/yapf/yapflib/pytree_unwrapper.py
+++ b/yapf/yapflib/pytree_unwrapper.py
@@ -31,8 +31,6 @@ For most uses, the convenience function UnwrapPyTree should be sufficient.
 from lib2to3 import pytree
 from lib2to3.pgen2 import token as grammar_token
 
-from yapf.yapflib import format_token
-from yapf.yapflib import object_state
 from yapf.yapflib import pytree_utils
 from yapf.yapflib import pytree_visitor
 from yapf.yapflib import split_penalty
@@ -110,7 +108,6 @@ class PyTreeUnwrapper(pytree_visitor.PyTreeVisitor):
     if self._cur_unwrapped_line.tokens:
       self._unwrapped_lines.append(self._cur_unwrapped_line)
       _MatchBrackets(self._cur_unwrapped_line)
-      _IdentifyParameterLists(self._cur_unwrapped_line)
       _AdjustSplitPenalty(self._cur_unwrapped_line)
     self._cur_unwrapped_line = unwrapped_line.UnwrappedLine(self._cur_depth)
 
@@ -323,39 +320,6 @@ def _MatchBrackets(uwline):
         token.container_opening = bracket
 
 
-def _IdentifyParameterLists(uwline):
-  """Visit the node to create a state for parameter lists.
-
-  For instance, a parameter is considered an "object" with its first and last
-  token uniquely identifying the object.
-
-  Arguments:
-    uwline: (UnwrappedLine) An unwrapped line.
-  """
-  func_stack = []
-  param_stack = []
-  for tok in uwline.tokens:
-    # Identify parameter list objects.
-    if format_token.Subtype.FUNC_DEF in tok.subtypes:
-      assert tok.next_token.value == '('
-      func_stack.append(tok.next_token)
-      continue
-
-    if func_stack and tok.value == ')':
-      if tok == func_stack[-1].matching_bracket:
-        func_stack.pop()
-      continue
-
-    # Identify parameter objects.
-    if format_token.Subtype.PARAMETER_START in tok.subtypes:
-      param_stack.append(tok)
-
-    # Not "elif", a parameter could be a single token.
-    if param_stack and format_token.Subtype.PARAMETER_STOP in tok.subtypes:
-      start = param_stack.pop()
-      func_stack[-1].parameters.append(object_state.Parameter(start, tok))
-
-
 def _AdjustSplitPenalty(uwline):
   """Visit the node and adjust the split penalties if needed.
 
diff --git a/yapf/yapflib/split_penalty.py b/yapf/yapflib/split_penalty.py
index e15ea2e..7f86d96 100644
--- a/yapf/yapflib/split_penalty.py
+++ b/yapf/yapflib/split_penalty.py
@@ -144,12 +144,6 @@ class _SplitPenaltyAssigner(pytree_visitor.PyTreeVisitor):
 
   def Visit_arglist(self, node):  # pylint: disable=invalid-name
     # arglist ::= argument (',' argument)* [',']
-    if pytree_utils.NodeName(node.children[0]) == 'STAR':
-      # Python 3 treats a star expression as a specific expression type.
-      # Process it in that method.
-      self.Visit_star_expr(node)
-      return
-
     self.DefaultNodeVisit(node)
 
     for index in py3compat.range(1, len(node.children)):
@@ -256,7 +250,10 @@ class _SplitPenaltyAssigner(pytree_visitor.PyTreeVisitor):
 
           # Bump up the split penalty for the first part of a subscript. We
           # would rather not split there.
-          _IncreasePenalty(node.children[1], CONNECTED)
+          first_leaf = pytree_utils.FirstLeafNode(node.children[1])
+          penalty = pytree_utils.GetNodeAnnotation(
+              first_leaf, pytree_utils.Annotation.SPLIT_PENALTY, default=0)
+          _SetSplitPenalty(first_leaf, penalty + CONNECTED)
         else:
           _SetStronglyConnected(node.children[1], node.children[2])
 
@@ -334,16 +331,6 @@ class _SplitPenaltyAssigner(pytree_visitor.PyTreeVisitor):
           # split the two.
           _SetStronglyConnected(trailer.children[-1])
 
-  def Visit_subscriptlist(self, node):  # pylint: disable=invalid-name
-    # subscriptlist ::= subscript (',' subscript)* [',']
-    self.DefaultNodeVisit(node)
-    _SetSplitPenalty(pytree_utils.FirstLeafNode(node), 0)
-    prev_child = None
-    for child in node.children:
-      if prev_child and pytree_utils.NodeName(prev_child) == 'COMMA':
-        _SetSplitPenalty(pytree_utils.FirstLeafNode(child), 0)
-      prev_child = child
-
   def Visit_subscript(self, node):  # pylint: disable=invalid-name
     # subscript ::= test | [test] ':' [test] [sliceop]
     _SetStronglyConnected(*node.children)
diff --git a/yapf/yapflib/style.py b/yapf/yapflib/style.py
index e614e62..48b3984 100644
--- a/yapf/yapflib/style.py
+++ b/yapf/yapflib/style.py
@@ -404,7 +404,6 @@ def CreateGoogleStyle():
   style['INDENT_WIDTH'] = 4
   style['I18N_COMMENT'] = r'#\..*'
   style['I18N_FUNCTION_CALL'] = ['N_', '_']
-  style['JOIN_MULTIPLE_LINES'] = False
   style['SPACE_BETWEEN_ENDING_COMMA_AND_CLOSING_BRACKET'] = False
   style['SPLIT_BEFORE_BITWISE_OPERATOR'] = False
   style['SPLIT_BEFORE_DICT_SET_GENERATOR'] = False
@@ -420,6 +419,7 @@ def CreateChromiumStyle():
   style['ALLOW_SPLIT_BEFORE_DEFAULT_OR_NAMED_ASSIGNS'] = False
   style['INDENT_DICTIONARY_VALUE'] = True
   style['INDENT_WIDTH'] = 2
+  style['JOIN_MULTIPLE_LINES'] = False
   style['SPLIT_BEFORE_BITWISE_OPERATOR'] = True
   style['SPLIT_BEFORE_DOT'] = True
   style['SPLIT_BEFORE_EXPRESSION_AFTER_OPENING_PAREN'] = True
diff --git a/yapf/yapflib/subtype_assigner.py b/yapf/yapflib/subtype_assigner.py
index 0fa2d96..dc36bbb 100644
--- a/yapf/yapflib/subtype_assigner.py
+++ b/yapf/yapflib/subtype_assigner.py
@@ -280,15 +280,6 @@ class _SubtypeAssigner(pytree_visitor.PyTreeVisitor):
     for child in node.children:
       self.Visit(child)
 
-  def Visit_parameters(self, node):  # pylint: disable=invalid-name
-    # parameters ::= '(' [typedargslist] ')'
-    self._ProcessArgLists(node)
-    if len(node.children) > 2:
-      _AppendFirstLeafTokenSubtype(node.children[1],
-                                   format_token.Subtype.PARAMETER_START)
-      _AppendLastLeafTokenSubtype(node.children[-2],
-                                  format_token.Subtype.PARAMETER_STOP)
-
   def Visit_typedargslist(self, node):  # pylint: disable=invalid-name
     # typedargslist ::=
     #     ((tfpdef ['=' test] ',')*
@@ -299,35 +290,16 @@ class _SubtypeAssigner(pytree_visitor.PyTreeVisitor):
     _SetArgListSubtype(node, format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN,
                        format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST)
     tname = False
-    if not node.children:
-      return
-
-    _AppendFirstLeafTokenSubtype(node.children[0],
-                                 format_token.Subtype.PARAMETER_START)
-    _AppendLastLeafTokenSubtype(node.children[-1],
-                                format_token.Subtype.PARAMETER_STOP)
-
-    i = 1
-    tname = pytree_utils.NodeName(node.children[0]) == 'tname'
-    while i < len(node.children):
-      prev_child = node.children[i - 1]
-      child = node.children[i]
-      i += 1
-
-      if pytree_utils.NodeName(prev_child) == 'COMMA':
-        _AppendFirstLeafTokenSubtype(child,
-                                     format_token.Subtype.PARAMETER_START)
-      elif pytree_utils.NodeName(child) == 'COMMA':
-        _AppendLastLeafTokenSubtype(prev_child,
-                                    format_token.Subtype.PARAMETER_STOP)
-
+    for child in node.children:
       if pytree_utils.NodeName(child) == 'tname':
         tname = True
         _SetArgListSubtype(child, format_token.Subtype.TYPED_NAME,
                            format_token.Subtype.TYPED_NAME_ARG_LIST)
-      elif pytree_utils.NodeName(child) == 'COMMA':
+      if not isinstance(child, pytree.Leaf):
+        continue
+      if child.value == ',':
         tname = False
-      elif pytree_utils.NodeName(child) == 'EQUAL' and tname:
+      elif child.value == '=' and tname:
         _AppendTokenSubtype(child, subtype=format_token.Subtype.TYPED_NAME)
         tname = False
 
@@ -418,14 +390,6 @@ def _AppendFirstLeafTokenSubtype(node, subtype):
   _AppendFirstLeafTokenSubtype(node.children[0], subtype)
 
 
-def _AppendLastLeafTokenSubtype(node, subtype):
-  """Append the last leaf token's subtypes."""
-  if isinstance(node, pytree.Leaf):
-    _AppendTokenSubtype(node, subtype)
-    return
-  _AppendLastLeafTokenSubtype(node.children[-1], subtype)
-
-
 def _AppendSubtypeRec(node, subtype, force=True):
   """Append the leafs in the node to the given subtype."""
   if isinstance(node, pytree.Leaf):
diff --git a/yapf/yapflib/unwrapped_line.py b/yapf/yapflib/unwrapped_line.py
index ff51db5..fb12755 100644
--- a/yapf/yapflib/unwrapped_line.py
+++ b/yapf/yapflib/unwrapped_line.py
@@ -329,9 +329,6 @@ def _SpaceRequiredBetween(left, right):
       # A string followed by something other than a subscript, closing bracket,
       # dot, or a binary op should have a space after it.
       return True
-    if format_token.Subtype.SUBSCRIPT_BRACKET in right.subtypes:
-      # It's legal to do this in Python: 'hello'[a]
-      return False
   if left.is_binary_op and lval != '**' and _IsUnaryOperator(right):
     # Space between the binary operator and the unary operator.
     return True
@@ -361,12 +358,8 @@ def _SpaceRequiredBetween(left, right):
     # The previous token was a unary op. No space is desired between it and
     # the current token.
     return False
-  if (format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN in left.subtypes and
-      format_token.Subtype.TYPED_NAME not in right.subtypes):
-    # A named argument or default parameter shouldn't have spaces around it.
-    return style.Get('SPACES_AROUND_DEFAULT_OR_NAMED_ASSIGN')
-  if (format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN in right.subtypes and
-      format_token.Subtype.TYPED_NAME not in left.subtypes):
+  if (format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN in left.subtypes or
+      format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN in right.subtypes):
     # A named argument or default parameter shouldn't have spaces around it.
     return style.Get('SPACES_AROUND_DEFAULT_OR_NAMED_ASSIGN')
   if (format_token.Subtype.VARARGS_LIST in left.subtypes or


Test patch:
diff --git a/yapftests/file_resources_test.py b/yapftests/file_resources_test.py
index 07e3134..eaf4b8b 100644
--- a/yapftests/file_resources_test.py
+++ b/yapftests/file_resources_test.py
@@ -36,16 +36,6 @@ def _restore_working_dir():
     os.chdir(curdir)
 
 
-@contextlib.contextmanager
-def _exists_mocked_in_module(module, mock_implementation):
-  unmocked_exists = getattr(module, 'exists')
-  setattr(module, 'exists', mock_implementation)
-  try:
-    yield
-  finally:
-    setattr(module, 'exists', unmocked_exists)
-
-
 class GetExcludePatternsForDir(unittest.TestCase):
 
   def setUp(self):  # pylint: disable=g-missing-super-call
@@ -102,43 +92,6 @@ class GetDefaultStyleForDirTest(unittest.TestCase):
     self.assertEqual(style_file,
                      file_resources.GetDefaultStyleForDir(test_filename))
 
-  def test_setup_config(self):
-    # An empty setup.cfg file should not be used
-    setup_config = os.path.join(self.test_tmpdir, 'setup.cfg')
-    open(setup_config, 'w').close()
-
-    test_dir = os.path.join(self.test_tmpdir, 'dir1')
-    style_name = file_resources.GetDefaultStyleForDir(test_dir)
-    self.assertEqual(style_name, 'pep8')
-
-    # One with a '[yapf]' section should be used
-    with open(setup_config, 'w') as f:
-      f.write('[yapf]\n')
-    self.assertEqual(setup_config,
-                     file_resources.GetDefaultStyleForDir(test_dir))
-
-  def test_local_style_at_root(self):
-    # Test behavior of files located on the root, and under root.
-    rootdir = os.path.abspath(os.path.sep)
-    test_dir_at_root = os.path.join(rootdir, 'dir1')
-    test_dir_under_root = os.path.join(rootdir, 'dir1', 'dir2')
-
-    # Fake placing only a style file at the root by mocking `os.path.exists`.
-    style_file = os.path.join(rootdir, '.style.yapf')
-
-    def mock_exists_implementation(path):
-      return path == style_file
-
-    with _exists_mocked_in_module(file_resources.os.path,
-                                  mock_exists_implementation):
-      # Both files should find the style file at the root.
-      default_style_at_root = file_resources.GetDefaultStyleForDir(
-          test_dir_at_root)
-      self.assertEqual(style_file, default_style_at_root)
-      default_style_under_root = file_resources.GetDefaultStyleForDir(
-          test_dir_under_root)
-      self.assertEqual(style_file, default_style_under_root)
-
 
 def _touch_files(filenames):
   for name in filenames:
diff --git a/yapftests/reformatter_buganizer_test.py b/yapftests/reformatter_buganizer_test.py
index eb0cc8a..4c30f72 100644
--- a/yapftests/reformatter_buganizer_test.py
+++ b/yapftests/reformatter_buganizer_test.py
@@ -28,54 +28,6 @@ class BuganizerFixes(yapf_test_helper.YAPFTest):
   def setUpClass(cls):
     style.SetGlobalStyle(style.CreateChromiumStyle())
 
-  def testB137580392(self):
-    code = """\
-def _create_testing_simulator_and_sink(
-) -> Tuple[_batch_simulator:_batch_simulator.BatchSimulator,
-           _batch_simulator.SimulationSink]:
-  pass
-"""
-    uwlines = yapf_test_helper.ParseAndUnwrap(code)
-    self.assertCodeEqual(code, reformatter.Reformat(uwlines))
-
-  def testB73279849(self):
-    unformatted_code = """\
-class A:
-    def _(a):
-        return 'hello'  [  a  ]
-"""
-    expected_formatted_code = """\
-class A:
-  def _(a):
-    return 'hello'[a]
-"""
-    uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
-    self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
-
-  def testB122455211(self):
-    unformatted_code = """\
-_zzzzzzzzzzzzzzzzzzzz = Union[sssssssssssssssssssss.pppppppppppppppp,
-                     sssssssssssssssssssss.pppppppppppppppppppppppppppp]
-"""
-    expected_formatted_code = """\
-_zzzzzzzzzzzzzzzzzzzz = Union[
-    sssssssssssssssssssss.pppppppppppppppp,
-    sssssssssssssssssssss.pppppppppppppppppppppppppppp]
-"""
-    uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
-    self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
-
-  def testB119300344(self):
-    code = """\
-def _GenerateStatsEntries(
-    process_id: Text,
-    timestamp: Optional[rdfvalue.RDFDatetime] = None
-) -> Sequence[stats_values.StatsStoreEntry]:
-  pass
-"""
-    uwlines = yapf_test_helper.ParseAndUnwrap(code)
-    self.assertCodeEqual(code, reformatter.Reformat(uwlines))
-
   def testB132886019(self):
     code = """\
 X = {
@@ -205,10 +157,10 @@ class Foo(object):
 class Foo(object):
 
   def testNoAlertForShortPeriod(self, rutabaga):
-    self.targets[:][
-        streamz_path,
-        self._fillInOtherFields(streamz_path, {streamz_field_of_interest: True}
-                               )] = series.Counter('1s', '+ 500x10000')
+    self.targets[:][streamz_path,
+                    self._fillInOtherFields(
+                        streamz_path, {streamz_field_of_interest: True}
+                    )] = series.Counter('1s', '+ 500x10000')
 """
     uwlines = yapf_test_helper.ParseAndUnwrap(unformatted_code)
     self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@@ -221,10 +173,9 @@ def xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(
     cccccccccc: AnyStr = cst.DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD,
     dddddddddd: Sequence[SliceDimension] = (),
     eeeeeeeeeeee: AnyStr = cst.DEFAULT_CONTROL_NAME,
-    ffffffffffffffffffff: Optional[Callable[[pd.DataFrame],
-                                            pd.DataFrame]] = None,
-    gggggggggggggg: ooooooooooooo = ooooooooooooo()
-) -> pd.DataFrame:
+    ffffffffffffffffffff: Optional[
+        Callable[[pd.DataFrame], pd.DataFrame]] = None,
+    gggggggggggggg: ooooooooooooo = ooooooooooooo()) -> pd.DataFrame:
   pass
 """
     uwlines = yapf_test_helper.ParseAndUnwrap(code)
@@ -1159,8 +1110,7 @@ class _():
             return 1
 
           def xxxxx(
-              self,
-              yyyyy,
+              self, yyyyy,
               zzzzzzzzzzzzzz=None):  # A normal comment that runs over the column limit.
             return 1
         """)
diff --git a/yapftests/reformatter_python3_test.py b/yapftests/reformatter_python3_test.py
index ff7bf74..9be6528 100644
--- a/yapftests/reformatter_python3_test.py
+++ b/yapftests/reformatter_python3_test.py
@@ -238,7 +238,7 @@ None.__ne__()
         """)
     expected_formatted_code = textwrap.dedent("""\
         def _ReduceAbstractContainers(
-            self, *args: Optional[automation_converter.PyiCollectionAbc]
+                self, *args: Optional[automation_converter.PyiCollectionAbc]
         ) -> List[automation_converter.PyiCollectionAbc]:
             pass
         """)
@@ -290,33 +290,33 @@ def run_sync_in_worker_thread(sync_fn, *args, cancellable=False, limiter=None):
 """
       expected_formatted_code = """\
 async def open_file(
-    file,
-    mode='r',
-    buffering=-1,
-    encoding=None,
-    errors=None,
-    newline=None,
-    closefd=True,
-    opener=None
+        file,
+        mode='r',
+        buffering=-1,
+        encoding=None,
+        errors=None,
+        newline=None,
+        closefd=True,
+        opener=None
 ):
     pass
 
 
 async def run_sync_in_worker_thread(
-    sync_fn, *args, cancellable=False, limiter=None
+        sync_fn, *args, cancellable=False, limiter=None
 ):
     pass
 
 
 def open_file(
-    file,
-    mode='r',
-    buffering=-1,
-    encoding=None,
-    errors=None,
-    newline=None,
-    closefd=True,
-    opener=None
+        file,
+        mode='r',
+        buffering=-1,
+        encoding=None,
+        errors=None,
+        newline=None,
+        closefd=True,
+        opener=None
 ):
     pass
 
@@ -378,26 +378,6 @@ def dirichlet(x12345678901234567890123456789012345678901234567890=...) -> None:
     uwlines = yapf_test_helper.ParseAndUnwrap(code)
     self.assertCodeEqual(code, reformatter.Reformat(uwlines))
 
-  def testFunctionTypedReturnNextLine(self):
-    code = """\
-def _GenerateStatsEntries(
-    process_id: Text,
-    timestamp: Optional[ffffffff.FFFFFFFFFFF] = None
-) -> Sequence[ssssssssssss.SSSSSSSSSSSSSSS]:
-    pass
-"""
-    uwlines = yapf_test_helper.ParseAndUnwrap(code)
-    self.assertCodeEqual(code, reformatter.Reformat(uwlines))
-
-  def testFunctionTypedReturnSameLine(self):
-    code = """\
-def rrrrrrrrrrrrrrrrrrrrrr(
-        ccccccccccccccccccccccc: Tuple[Text, Text]) -> List[Tuple[Text, Text]]:
-    pass
-"""
-    uwlines = yapf_test_helper.ParseAndUnwrap(code)
-    self.assertCodeEqual(code, reformatter.Reformat(uwlines))
-
 
 if __name__ == '__main__':
   unittest.main()
diff --git a/yapftests/subtype_assigner_test.py b/yapftests/subtype_assigner_test.py
index b42b8cf..ef864f8 100644
--- a/yapftests/subtype_assigner_test.py
+++ b/yapftests/subtype_assigner_test.py
@@ -43,66 +43,41 @@ class SubtypeAssignerTest(yapf_test_helper.YAPFTest):
     self.assertEqual(list_of_expected, actual)
 
   def testFuncDefDefaultAssign(self):
-    self.maxDiff = None  # pylint: disable=invalid-name
     code = textwrap.dedent(r"""
         def foo(a=37, *b, **c):
           return -x[:42]
         """)
     uwlines = yapf_test_helper.ParseAndUnwrap(code)
     self._CheckFormatTokenSubtypes(uwlines, [
-        [
-            ('def', [format_token.Subtype.NONE]),
-            ('foo', {format_token.Subtype.FUNC_DEF}),
-            ('(', {format_token.Subtype.NONE}),
-            ('a', {
-                format_token.Subtype.NONE,
-                format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST,
-                format_token.Subtype.PARAMETER_START,
-            }),
-            ('=', {
-                format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN,
-                format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST,
-            }),
-            ('37', {
-                format_token.Subtype.NONE,
-                format_token.Subtype.PARAMETER_STOP,
-                format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST,
-            }),
-            (',', {format_token.Subtype.NONE}),
-            ('*', {
-                format_token.Subtype.PARAMETER_START,
-                format_token.Subtype.VARARGS_STAR,
-                format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST,
-            }),
-            ('b', {
-                format_token.Subtype.NONE,
-                format_token.Subtype.PARAMETER_STOP,
-                format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST,
-            }),
-            (',', {format_token.Subtype.NONE}),
-            ('**', {
-                format_token.Subtype.PARAMETER_START,
-                format_token.Subtype.KWARGS_STAR_STAR,
-                format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST,
-            }),
-            ('c', {
-                format_token.Subtype.NONE,
-                format_token.Subtype.PARAMETER_STOP,
-                format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST,
-            }),
-            (')', {format_token.Subtype.NONE}),
-            (':', [format_token.Subtype.NONE]),
-        ],
-        [
-            ('return', [format_token.Subtype.NONE]),
-            ('-', {format_token.Subtype.UNARY_OPERATOR}),
-            ('x', [format_token.Subtype.NONE]),
-            ('[', {format_token.Subtype.SUBSCRIPT_BRACKET}),
-            (':', {format_token.Subtype.SUBSCRIPT_COLON}),
-            ('42', [format_token.Subtype.NONE]),
-            (']', {format_token.Subtype.SUBSCRIPT_BRACKET}),
-        ],
-    ])
+        [('def', [format_token.Subtype.NONE]),
+         ('foo', {format_token.Subtype.FUNC_DEF}),
+         ('(', [format_token.Subtype.NONE]),
+         ('a', {format_token.Subtype.NONE,
+                format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST}),
+         ('=', {format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN,
+                format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST}),
+         ('37', {format_token.Subtype.NONE,
+                 format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST}),
+         (',', {format_token.Subtype.NONE}),
+         ('*', {format_token.Subtype.VARARGS_STAR,
+                format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST}),
+         ('b', {format_token.Subtype.NONE,
+                format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST}),
+         (',', {format_token.Subtype.NONE}),
+         ('**', {format_token.Subtype.KWARGS_STAR_STAR,
+                 format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST}),
+         ('c', {format_token.Subtype.NONE,
+                format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST}),
+         (')', [format_token.Subtype.NONE]),
+         (':', [format_token.Subtype.NONE])],
+        [('return', [format_token.Subtype.NONE]),
+         ('-', {format_token.Subtype.UNARY_OPERATOR}),
+         ('x', [format_token.Subtype.NONE]),
+         ('[', {format_token.Subtype.SUBSCRIPT_BRACKET}),
+         (':', {format_token.Subtype.SUBSCRIPT_COLON}),
+         ('42', [format_token.Subtype.NONE]),
+         (']', {format_token.Subtype.SUBSCRIPT_BRACKET})],
+    ])  # yapf: disable
 
   def testFuncCallWithDefaultAssign(self):
     code = textwrap.dedent(r"""
@@ -110,23 +85,17 @@ class SubtypeAssignerTest(yapf_test_helper.YAPFTest):
         """)
     uwlines = yapf_test_helper.ParseAndUnwrap(code)
     self._CheckFormatTokenSubtypes(uwlines, [
-        [
-            ('foo', [format_token.Subtype.NONE]),
-            ('(', [format_token.Subtype.NONE]),
-            ('x', {
-                format_token.Subtype.NONE,
-                format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST,
-            }),
-            (',', {format_token.Subtype.NONE}),
-            ('a', {
-                format_token.Subtype.NONE,
-                format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST,
-            }),
-            ('=', {format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN}),
-            ("'hello world'", {format_token.Subtype.NONE}),
-            (')', [format_token.Subtype.NONE]),
-        ],
-    ])
+        [('foo', [format_token.Subtype.NONE]),
+         ('(', [format_token.Subtype.NONE]),
+         ('x', {format_token.Subtype.NONE,
+                format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST}),
+         (',', {format_token.Subtype.NONE}),
+         ('a', {format_token.Subtype.NONE,
+                format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST}),
+         ('=', {format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN}),
+         ("'hello world'", {format_token.Subtype.NONE}),
+         (')', [format_token.Subtype.NONE])],
+    ])  # yapf: disable
 
   def testSetComprehension(self):
     code = textwrap.dedent("""\
@@ -135,45 +104,36 @@ class SubtypeAssignerTest(yapf_test_helper.YAPFTest):
         """)
     uwlines = yapf_test_helper.ParseAndUnwrap(code)
     self._CheckFormatTokenSubtypes(uwlines, [
-        [
-            ('def', [format_token.Subtype.NONE]),
-            ('foo', {format_token.Subtype.FUNC_DEF}),
-            ('(', {format_token.Subtype.NONE}),
-            ('strs', {
-                format_token.Subtype.NONE,
-                format_token.Subtype.PARAMETER_START,
-                format_token.Subtype.PARAMETER_STOP,
-            }),
-            (')', {format_token.Subtype.NONE}),
-            (':', [format_token.Subtype.NONE]),
-        ],
-        [
-            ('return', [format_token.Subtype.NONE]),
-            ('{', [format_token.Subtype.NONE]),
-            ('s', {format_token.Subtype.COMP_EXPR}),
-            ('.', {format_token.Subtype.COMP_EXPR}),
-            ('lower', {format_token.Subtype.COMP_EXPR}),
-            ('(', {format_token.Subtype.COMP_EXPR}),
-            (')', {format_token.Subtype.COMP_EXPR}),
-            ('for', {
-                format_token.Subtype.DICT_SET_GENERATOR,
-                format_token.Subtype.COMP_FOR,
-            }),
-            ('s', {format_token.Subtype.COMP_FOR}),
-            ('in', {format_token.Subtype.COMP_FOR}),
-            ('strs', {format_token.Subtype.COMP_FOR}),
-            ('}', [format_token.Subtype.NONE]),
-        ],
-    ])
+        [('def', [format_token.Subtype.NONE]),
+         ('foo', {format_token.Subtype.FUNC_DEF}),
+         ('(', [format_token.Subtype.NONE]),
+         ('strs', [format_token.Subtype.NONE]),
+         (')', [format_token.Subtype.NONE]),
+         (':', [format_token.Subtype.NONE])],
+        [('return', [format_token.Subtype.NONE]),
+         ('{', [format_token.Subtype.NONE]),
+         ('s', {format_token.Subtype.COMP_EXPR}),
+         ('.', {format_token.Subtype.COMP_EXPR}),
+         ('lower', {format_token.Subtype.COMP_EXPR}),
+         ('(', {format_token.Subtype.COMP_EXPR}),
+         (')', {format_token.Subtype.COMP_EXPR}),
+         ('for', {format_token.Subtype.DICT_SET_GENERATOR,
+                  format_token.Subtype.COMP_FOR}),
+         ('s', {format_token.Subtype.COMP_FOR}),
+         ('in', {format_token.Subtype.COMP_FOR}),
+         ('strs', {format_token.Subtype.COMP_FOR}),
+         ('}', [format_token.Subtype.NONE])]
+    ])  # yapf: disable
 
   def testUnaryNotOperator(self):
     code = textwrap.dedent("""\
         not a
         """)
     uwlines = yapf_test_helper.ParseAndUnwrap(code)
-    self._CheckFormatTokenSubtypes(
-        uwlines, [[('not', {format_token.Subtype.UNARY_OPERATOR}),
-                   ('a', [format_token.Subtype.NONE])]])
+    self._CheckFormatTokenSubtypes(uwlines, [
+        [('not', {format_token.Subtype.UNARY_OPERATOR}),
+         ('a', [format_token.Subtype.NONE])]
+    ])  # yapf: disable
 
   def testBitwiseOperators(self):
     code = textwrap.dedent("""\
@@ -181,28 +141,26 @@ class SubtypeAssignerTest(yapf_test_helper.YAPFTest):
         """)
     uwlines = yapf_test_helper.ParseAndUnwrap(code)
     self._CheckFormatTokenSubtypes(uwlines, [
-        [
-            ('x', [format_token.Subtype.NONE]),
-            ('=', {format_token.Subtype.ASSIGN_OPERATOR}),
-            ('(', [format_token.Subtype.NONE]),
-            ('(', [format_token.Subtype.NONE]),
-            ('a', [format_token.Subtype.NONE]),
-            ('|', {format_token.Subtype.BINARY_OPERATOR}),
-            ('(', [format_token.Subtype.NONE]),
-            ('b', [format_token.Subtype.NONE]),
-            ('^', {format_token.Subtype.BINARY_OPERATOR}),
-            ('3', [format_token.Subtype.NONE]),
-            (')', [format_token.Subtype.NONE]),
-            ('&', {format_token.Subtype.BINARY_OPERATOR}),
-            ('c', [format_token.Subtype.NONE]),
-            (')', [format_token.Subtype.NONE]),
-            ('<<', {format_token.Subtype.BINARY_OPERATOR}),
-            ('3', [format_token.Subtype.NONE]),
-            (')', [format_token.Subtype.NONE]),
-            ('>>', {format_token.Subtype.BINARY_OPERATOR}),
-            ('1', [format_token.Subtype.NONE]),
-        ],
-    ])
+        [('x', [format_token.Subtype.NONE]),
+         ('=', {format_token.Subtype.ASSIGN_OPERATOR}),
+         ('(', [format_token.Subtype.NONE]),
+         ('(', [format_token.Subtype.NONE]),
+         ('a', [format_token.Subtype.NONE]),
+         ('|', {format_token.Subtype.BINARY_OPERATOR}),
+         ('(', [format_token.Subtype.NONE]),
+         ('b', [format_token.Subtype.NONE]),
+         ('^', {format_token.Subtype.BINARY_OPERATOR}),
+         ('3', [format_token.Subtype.NONE]),
+         (')', [format_token.Subtype.NONE]),
+         ('&', {format_token.Subtype.BINARY_OPERATOR}),
+         ('c', [format_token.Subtype.NONE]),
+         (')', [format_token.Subtype.NONE]),
+         ('<<', {format_token.Subtype.BINARY_OPERATOR}),
+         ('3', [format_token.Subtype.NONE]),
+         (')', [format_token.Subtype.NONE]),
+         ('>>', {format_token.Subtype.BINARY_OPERATOR}),
+         ('1', [format_token.Subtype.NONE]),],
+    ])  # yapf: disable
 
   def testArithmeticOperators(self):
     code = textwrap.dedent("""\
@@ -210,57 +168,41 @@ class SubtypeAssignerTest(yapf_test_helper.YAPFTest):
         """)
     uwlines = yapf_test_helper.ParseAndUnwrap(code)
     self._CheckFormatTokenSubtypes(uwlines, [
-        [
-            ('x', [format_token.Subtype.NONE]),
-            ('=', {format_token.Subtype.ASSIGN_OPERATOR}),
-            ('(', [format_token.Subtype.NONE]),
-            ('(', [format_token.Subtype.NONE]),
-            ('a', [format_token.Subtype.NONE]),
-            ('+', {
-                format_token.Subtype.BINARY_OPERATOR,
-                format_token.Subtype.A_EXPR_OPERATOR,
-            }),
-            ('(', [format_token.Subtype.NONE]),
-            ('b', [format_token.Subtype.NONE]),
-            ('-', {
-                format_token.Subtype.BINARY_OPERATOR,
+        [('x', [format_token.Subtype.NONE]),
+         ('=', {format_token.Subtype.ASSIGN_OPERATOR}),
+         ('(', [format_token.Subtype.NONE]),
+         ('(', [format_token.Subtype.NONE]),
+         ('a', [format_token.Subtype.NONE]),
+         ('+', {format_token.Subtype.BINARY_OPERATOR,
+                format_token.Subtype.A_EXPR_OPERATOR}),
+         ('(', [format_token.Subtype.NONE]),
+         ('b', [format_token.Subtype.NONE]),
+         ('-', {format_token.Subtype.BINARY_OPERATOR,
                 format_token.Subtype.A_EXPR_OPERATOR,
-                format_token.Subtype.SIMPLE_EXPRESSION,
-            }),
-            ('3', [format_token.Subtype.NONE]),
-            (')', [format_token.Subtype.NONE]),
-            ('*', {
-                format_token.Subtype.BINARY_OPERATOR,
-                format_token.Subtype.M_EXPR_OPERATOR,
-            }),
-            ('(', [format_token.Subtype.NONE]),
-            ('1', [format_token.Subtype.NONE]),
-            ('%', {
-                format_token.Subtype.BINARY_OPERATOR,
+                format_token.Subtype.SIMPLE_EXPRESSION}),
+         ('3', [format_token.Subtype.NONE]),
+         (')', [format_token.Subtype.NONE]),
+         ('*', {format_token.Subtype.BINARY_OPERATOR,
+                format_token.Subtype.M_EXPR_OPERATOR}),
+         ('(', [format_token.Subtype.NONE]),
+         ('1', [format_token.Subtype.NONE]),
+         ('%', {format_token.Subtype.BINARY_OPERATOR,
                 format_token.Subtype.M_EXPR_OPERATOR,
-                format_token.Subtype.SIMPLE_EXPRESSION,
-            }),
-            ('c', [format_token.Subtype.NONE]),
-            (')', [format_token.Subtype.NONE]),
-            ('@', {
-                format_token.Subtype.BINARY_OPERATOR,
-                format_token.Subtype.M_EXPR_OPERATOR,
-            }),
-            ('d', [format_token.Subtype.NONE]),
-            (')', [format_token.Subtype.NONE]),
-            ('/', {
-                format_token.Subtype.BINARY_OPERATOR,
-                format_token.Subtype.M_EXPR_OPERATOR,
-            }),
-            ('3', [format_token.Subtype.NONE]),
-            (')', [format_token.Subtype.NONE]),
-            ('//', {
-                format_token.Subtype.BINARY_OPERATOR,
-                format_token.Subtype.M_EXPR_OPERATOR,
-            }),
-            ('1', [format_token.Subtype.NONE]),
-        ],
-    ])
+                format_token.Subtype.SIMPLE_EXPRESSION}),
+         ('c', [format_token.Subtype.NONE]),
+         (')', [format_token.Subtype.NONE]),
+         ('@', {format_token.Subtype.BINARY_OPERATOR,
+                format_token.Subtype.M_EXPR_OPERATOR}),
+         ('d', [format_token.Subtype.NONE]),
+         (')', [format_token.Subtype.NONE]),
+         ('/', {format_token.Subtype.BINARY_OPERATOR,
+                format_token.Subtype.M_EXPR_OPERATOR}),
+         ('3', [format_token.Subtype.NONE]),
+         (')', [format_token.Subtype.NONE]),
+         ('//', {format_token.Subtype.BINARY_OPERATOR,
+                 format_token.Subtype.M_EXPR_OPERATOR}),
+         ('1', [format_token.Subtype.NONE]),],
+    ])  # yapf: disable
 
   def testSubscriptColon(self):
     code = textwrap.dedent("""\
@@ -286,18 +228,14 @@ class SubtypeAssignerTest(yapf_test_helper.YAPFTest):
         """)
     uwlines = yapf_test_helper.ParseAndUnwrap(code)
     self._CheckFormatTokenSubtypes(uwlines, [
-        [
-            ('[', [format_token.Subtype.NONE]),
-            ('a', [format_token.Subtype.NONE]),
-            (',', [format_token.Subtype.NONE]),
-            ('*', {
-                format_token.Subtype.UNARY_OPERATOR,
-                format_token.Subtype.VARARGS_STAR,
-            }),
-            ('b', [format_token.Subtype.NONE]),
-            (']', [format_token.Subtype.NONE]),
-        ],
-    ])
+        [('[', [format_token.Subtype.NONE]),
+         ('a', [format_token.Subtype.NONE]),
+         (',', [format_token.Subtype.NONE]),
+         ('*', {format_token.Subtype.UNARY_OPERATOR,
+                format_token.Subtype.VARARGS_STAR}),
+         ('b', [format_token.Subtype.NONE]),
+         (']', [format_token.Subtype.NONE]),],
+    ])  # yapf: disable
 
 
 if __name__ == '__main__':
diff --git a/yapftests/yapf_test.py b/yapftests/yapf_test.py
index e13955f..a257200 100644
--- a/yapftests/yapf_test.py
+++ b/yapftests/yapf_test.py
@@ -1710,12 +1710,12 @@ class HorizontallyAlignedTrailingCommentsTest(yapf_test_helper.YAPFTest):
         """)
     expected_formatted_code = textwrap.dedent("""\
         def MyFunc(
-            arg1,               # Desc 1
-            arg2,               # Desc 2
-            a_longer_var_name,  # Desc 3
-            arg4,
-            arg5,               # Desc 5
-            arg6,
+                arg1,                     # Desc 1
+                arg2,                     # Desc 2
+                a_longer_var_name,        # Desc 3
+                arg4,
+                arg5,                     # Desc 5
+                arg6,
         ):
             pass
         """)