Split after an opening bracket if named assigns

When we intentionally split each argument because of a named assignment, then
also split after the opening bracket (before the first argument). This makes
things a bit nicer to look at. It also allows one to rename the function
without having to reformat all of the arguments to the function call.
diff --git a/CHANGELOG b/CHANGELOG
index 30f807d..7dfea27 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,11 @@
   DEDENT_CLOSING_BRACKETS is set.
 - Don't count "pylint" directives as exceeding the column limit.
 
+### Changed
+- We split all of the arguments to a function call if there's a named argument.
+  In this case, we want to split before the opening bracket too. This makes
+  things look a bit better.
+
 ### Fixed
 - When retaining format of a multiline string with Chromium style, make sure
   that the multiline string doesn't mess up where the following comma ends up.
diff --git a/setup.py b/setup.py
index e157d6a..59042c0 100644
--- a/setup.py
+++ b/setup.py
@@ -39,29 +39,30 @@
 
 
 with codecs.open('README.rst', 'r', 'utf-8') as fd:
-  setup(name='yapf',
-        version=yapf.__version__,
-        description='A formatter for Python code.',
-        long_description=fd.read(),
-        license='Apache License, Version 2.0',
-        author='Google Inc.',
-        maintainer='Bill Wendling',
-        maintainer_email='[email protected]',
-        packages=['yapf', 'yapf.yapflib', 'yapftests'],
-        classifiers=[
-            'Development Status :: 4 - Beta',
-            'Environment :: Console',
-            'Intended Audience :: Developers',
-            'License :: OSI Approved :: Apache Software License',
-            'Operating System :: OS Independent',
-            'Programming Language :: Python',
-            'Programming Language :: Python :: 2',
-            'Programming Language :: Python :: 2.7',
-            'Programming Language :: Python :: 3',
-            'Programming Language :: Python :: 3.4',
-            'Programming Language :: Python :: 3.5',
-            'Topic :: Software Development :: Libraries :: Python Modules',
-            'Topic :: Software Development :: Quality Assurance',
-        ],
-        entry_points={'console_scripts': ['yapf = yapf:run_main'],},
-        cmdclass={'test': RunTests,},)
+  setup(
+      name='yapf',
+      version=yapf.__version__,
+      description='A formatter for Python code.',
+      long_description=fd.read(),
+      license='Apache License, Version 2.0',
+      author='Google Inc.',
+      maintainer='Bill Wendling',
+      maintainer_email='[email protected]',
+      packages=['yapf', 'yapf.yapflib', 'yapftests'],
+      classifiers=[
+          'Development Status :: 4 - Beta',
+          'Environment :: Console',
+          'Intended Audience :: Developers',
+          'License :: OSI Approved :: Apache Software License',
+          'Operating System :: OS Independent',
+          'Programming Language :: Python',
+          'Programming Language :: Python :: 2',
+          'Programming Language :: Python :: 2.7',
+          'Programming Language :: Python :: 3',
+          'Programming Language :: Python :: 3.4',
+          'Programming Language :: Python :: 3.5',
+          'Topic :: Software Development :: Libraries :: Python Modules',
+          'Topic :: Software Development :: Quality Assurance',
+      ],
+      entry_points={'console_scripts': ['yapf = yapf:run_main'],},
+      cmdclass={'test': RunTests,},)
diff --git a/yapf/__init__.py b/yapf/__init__.py
index 8bb664b..4f63b29 100644
--- a/yapf/__init__.py
+++ b/yapf/__init__.py
@@ -55,26 +55,30 @@
     YapfError: if none of the supplied files were Python files.
   """
   parser = argparse.ArgumentParser(description='Formatter for Python code.')
-  parser.add_argument('-v',
-                      '--version',
-                      action='store_true',
-                      help='show version number and exit')
+  parser.add_argument(
+      '-v',
+      '--version',
+      action='store_true',
+      help='show version number and exit')
 
   diff_inplace_group = parser.add_mutually_exclusive_group()
-  diff_inplace_group.add_argument('-d',
-                                  '--diff',
-                                  action='store_true',
-                                  help='print the diff for the fixed source')
-  diff_inplace_group.add_argument('-i',
-                                  '--in-place',
-                                  action='store_true',
-                                  help='make changes to files in place')
+  diff_inplace_group.add_argument(
+      '-d',
+      '--diff',
+      action='store_true',
+      help='print the diff for the fixed source')
+  diff_inplace_group.add_argument(
+      '-i',
+      '--in-place',
+      action='store_true',
+      help='make changes to files in place')
 
   lines_recursive_group = parser.add_mutually_exclusive_group()
-  lines_recursive_group.add_argument('-r',
-                                     '--recursive',
-                                     action='store_true',
-                                     help='run recursively over directories')
+  lines_recursive_group.add_argument(
+      '-r',
+      '--recursive',
+      action='store_true',
+      help='run recursively over directories')
   lines_recursive_group.add_argument(
       '-l',
       '--lines',
@@ -83,12 +87,13 @@
       default=None,
       help='range of lines to reformat, one-based')
 
-  parser.add_argument('-e',
-                      '--exclude',
-                      metavar='PATTERN',
-                      action='append',
-                      default=None,
-                      help='patterns for files to exclude from formatting')
+  parser.add_argument(
+      '-e',
+      '--exclude',
+      metavar='PATTERN',
+      action='append',
+      default=None,
+      help='patterns for files to exclude from formatting')
   parser.add_argument(
       '--style',
       action='store',
@@ -97,14 +102,16 @@
             'default is pep8 unless a %s or %s file located in one of the '
             'parent directories of the source file (or current directory for '
             'stdin)' % (style.LOCAL_STYLE, style.SETUP_CONFIG)))
-  parser.add_argument('--style-help',
-                      action='store_true',
-                      help=('show style settings and exit; this output can be '
-                            'saved to .style.yapf to make your settings '
-                            'permanent'))
-  parser.add_argument('--no-local-style',
-                      action='store_true',
-                      help="don't search for local style definition")
+  parser.add_argument(
+      '--style-help',
+      action='store_true',
+      help=('show style settings and exit; this output can be '
+            'saved to .style.yapf to make your settings '
+            'permanent'))
+  parser.add_argument(
+      '--no-local-style',
+      action='store_true',
+      help="don't search for local style definition")
   parser.add_argument('--verify', action='store_true', help=argparse.SUPPRESS)
 
   parser.add_argument('files', nargs='*')
@@ -160,13 +167,14 @@
                                              args.exclude)
   if not files:
     raise errors.YapfError('Input filenames did not match any python files')
-  changed = FormatFiles(files,
-                        lines,
-                        style_config=args.style,
-                        no_local_style=args.no_local_style,
-                        in_place=args.in_place,
-                        print_diff=args.diff,
-                        verify=args.verify)
+  changed = FormatFiles(
+      files,
+      lines,
+      style_config=args.style,
+      no_local_style=args.no_local_style,
+      in_place=args.in_place,
+      print_diff=args.diff,
+      verify=args.verify)
   return 2 if changed else 0
 
 
diff --git a/yapf/yapflib/comment_splicer.py b/yapf/yapflib/comment_splicer.py
index 0690331..d7c9536 100644
--- a/yapf/yapflib/comment_splicer.py
+++ b/yapf/yapflib/comment_splicer.py
@@ -72,10 +72,11 @@
             comment_column -= len(comment_prefix)
             comment_column += len(comment_prefix) - len(comment_prefix.lstrip())
             pytree_utils.InsertNodesAfter(
-                _CreateCommentsFromPrefix(comment_prefix,
-                                          comment_lineno,
-                                          comment_column,
-                                          standalone=False),
+                _CreateCommentsFromPrefix(
+                    comment_prefix,
+                    comment_lineno,
+                    comment_column,
+                    standalone=False),
                 prev_leaf[0])
           elif child.type == token.DEDENT:
             # Comment prefixes on DEDENT nodes also deserve special treatment,
@@ -117,26 +118,29 @@
               # Special case where the comment is inserted in the same
               # indentation level as the DEDENT it was originally attached to.
               pytree_utils.InsertNodesBefore(
-                  _CreateCommentsFromPrefix('\n'.join(before) + '\n',
-                                            comment_lineno,
-                                            comment_column,
-                                            standalone=True),
+                  _CreateCommentsFromPrefix(
+                      '\n'.join(before) + '\n',
+                      comment_lineno,
+                      comment_column,
+                      standalone=True),
                   ancestor_at_indent)
               if after:
                 after_column = len(after[0]) - len(after[0].lstrip())
                 comment_column -= comment_column - after_column
                 pytree_utils.InsertNodesAfter(
-                    _CreateCommentsFromPrefix('\n'.join(after) + '\n',
-                                              after_lineno,
-                                              comment_column,
-                                              standalone=True),
+                    _CreateCommentsFromPrefix(
+                        '\n'.join(after) + '\n',
+                        after_lineno,
+                        comment_column,
+                        standalone=True),
                     _FindNextAncestor(ancestor_at_indent))
             else:
               pytree_utils.InsertNodesAfter(
-                  _CreateCommentsFromPrefix(comment_prefix,
-                                            comment_lineno,
-                                            comment_column,
-                                            standalone=True),
+                  _CreateCommentsFromPrefix(
+                      comment_prefix,
+                      comment_lineno,
+                      comment_column,
+                      standalone=True),
                   ancestor_at_indent)
           else:
             # Otherwise there are two cases.
@@ -162,10 +166,8 @@
                 # _STANDALONE_LINE_NODES for more details.
                 node_with_line_parent = _FindNodeWithStandaloneLineParent(child)
                 pytree_utils.InsertNodesBefore(
-                    _CreateCommentsFromPrefix(comment_prefix,
-                                              comment_lineno,
-                                              0,
-                                              standalone=True),
+                    _CreateCommentsFromPrefix(
+                        comment_prefix, comment_lineno, 0, standalone=True),
                     node_with_line_parent)
                 break
               else:
@@ -187,10 +189,11 @@
                           comment_prefix.rstrip().rindex('\n') + 1)
                 comment_column = (len(comment_prefix[rindex:]) -
                                   len(comment_prefix[rindex:].lstrip()))
-                comments = _CreateCommentsFromPrefix(comment_prefix,
-                                                     comment_lineno,
-                                                     comment_column,
-                                                     standalone=False)
+                comments = _CreateCommentsFromPrefix(
+                    comment_prefix,
+                    comment_lineno,
+                    comment_column,
+                    standalone=False)
                 pytree_utils.InsertNodesBefore(comments, child)
                 break
 
@@ -233,9 +236,10 @@
       new_lineno = comment_lineno + index - 1
       comment_block[0] = comment_block[0].lstrip()
       comment_block[-1] = comment_block[-1].rstrip('\n')
-      comment_leaf = pytree.Leaf(type=token.COMMENT,
-                                 value='\n'.join(comment_block),
-                                 context=('', (new_lineno, comment_column)))
+      comment_leaf = pytree.Leaf(
+          type=token.COMMENT,
+          value='\n'.join(comment_block),
+          context=('', (new_lineno, comment_column)))
       comment_node = comment_leaf if not standalone else pytree.Node(
           pygram.python_symbols.simple_stmt, [comment_leaf])
       comments.append(comment_node)
diff --git a/yapf/yapflib/continuation_splicer.py b/yapf/yapflib/continuation_splicer.py
index 2aa428d..a1a2020 100644
--- a/yapf/yapflib/continuation_splicer.py
+++ b/yapf/yapflib/continuation_splicer.py
@@ -36,9 +36,10 @@
     if isinstance(node, pytree.Leaf):
       if node.prefix.lstrip().startswith('\\\n'):
         new_lineno = node.lineno - node.prefix.count('\n')
-        return pytree.Leaf(type=format_token.CONTINUATION,
-                           value=node.prefix,
-                           context=('', (new_lineno, 0)))
+        return pytree.Leaf(
+            type=format_token.CONTINUATION,
+            value=node.prefix,
+            context=('', (new_lineno, 0)))
       return None
     num_inserted = 0
     for index, child in enumerate(node.children[:]):
diff --git a/yapf/yapflib/file_resources.py b/yapf/yapflib/file_resources.py
index 3332a89..a39f0f1 100644
--- a/yapf/yapflib/file_resources.py
+++ b/yapf/yapflib/file_resources.py
@@ -85,9 +85,8 @@
     encoding: (unicode) The encoding of the file.
   """
   if in_place:
-    with py3compat.open_with_encoding(filename,
-                                      mode='w',
-                                      encoding=encoding) as fd:
+    with py3compat.open_with_encoding(
+        filename, mode='w', encoding=encoding) as fd:
       fd.write(reformatted_code)
   else:
     py3compat.EncodeAndWriteToStdout(reformatted_code, encoding)
@@ -138,9 +137,8 @@
     return False
 
   try:
-    with py3compat.open_with_encoding(filename,
-                                      mode='r',
-                                      encoding=encoding) as fd:
+    with py3compat.open_with_encoding(
+        filename, mode='r', encoding=encoding) as fd:
       first_line = fd.readlines()[0]
   except (IOError, IndexError):
     return False
diff --git a/yapf/yapflib/format_decision_state.py b/yapf/yapflib/format_decision_state.py
index 95bc4c0..c543065 100644
--- a/yapf/yapflib/format_decision_state.py
+++ b/yapf/yapflib/format_decision_state.py
@@ -172,13 +172,28 @@
     if (style.Get('SPLIT_BEFORE_NAMED_ASSIGNS') and
         format_token.Subtype.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST in
         current.subtypes):
-      if (previous.value not in {'(', '=', '*', '**'} and
+      if (previous.value not in {'=', '*', '**'} and
           current.value not in '=,)'):
-        opening = _GetOpeningParen(current)
-        if opening:
-          arglist_length = (opening.matching_bracket.total_length -
-                            opening.total_length + self.column)
-          return arglist_length > column_limit
+        # If we're going to split the lines because of named arguments, then we
+        # want to split after the opening bracket as well. But not when this is
+        # part of function definition.
+        if not _IsFunctionDefinition(previous):
+          # 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)
+          indent_amt = self.stack[-1].indent * style.Get('INDENT_WIDTH')
+          pptoken = previous.previous_token
+          opening_column = len(pptoken.value) if pptoken else 0 - indent_amt - 1
+          if previous.value == '(':
+            return opening_column >= style.Get('CONTINUATION_INDENT_WIDTH')
+          opening = _GetOpeningParen(current)
+          if opening:
+            arglist_length = (opening.matching_bracket.total_length -
+                              opening.total_length + self.stack[-1].indent)
+            return arglist_length > column_limit
 
     if style.Get('SPLIT_ARGUMENTS_WHEN_COMMA_TERMINATED'):
       # Split before arguments in a function call or definition if the
@@ -501,6 +516,12 @@
   return current
 
 
+def _IsFunctionDefinition(current):
+  prev = current.previous_token
+  return (current.value == '(' and prev and
+          format_token.Subtype.FUNC_DEF in prev.subtypes)
+
+
 def _IsLastScopeInLine(current):
   while current:
     current = current.next_token
diff --git a/yapf/yapflib/format_token.py b/yapf/yapflib/format_token.py
index b63dd4f..32d11c9 100644
--- a/yapf/yapflib/format_token.py
+++ b/yapf/yapflib/format_token.py
@@ -50,6 +50,7 @@
   COMP_FOR = 12
   COMP_IF = 13
   DEFAULT_OR_NAMED_ASSIGN_ARG_LIST = 14
+  FUNC_DEF = 15
 
 
 class FormatToken(object):
@@ -183,9 +184,8 @@
   @py3compat.lru_cache()
   def node_split_penalty(self):
     """Split penalty attached to the pytree node of this token."""
-    return pytree_utils.GetNodeAnnotation(self.node,
-                                          pytree_utils.Annotation.SPLIT_PENALTY,
-                                          default=0)
+    return pytree_utils.GetNodeAnnotation(
+        self.node, pytree_utils.Annotation.SPLIT_PENALTY, default=0)
 
   @property
   def newlines(self):
diff --git a/yapf/yapflib/pytree_utils.py b/yapf/yapflib/pytree_utils.py
index 1244005..9fea5e6 100644
--- a/yapf/yapflib/pytree_utils.py
+++ b/yapf/yapflib/pytree_utils.py
@@ -267,16 +267,18 @@
   """
   if isinstance(node, pytree.Leaf):
     fmt = '{name}({value}) [lineno={lineno}, column={column}, prefix={prefix}]'
-    return fmt.format(name=NodeName(node),
-                      value=_PytreeNodeRepr(node),
-                      lineno=node.lineno,
-                      column=node.column,
-                      prefix=repr(node.prefix))
+    return fmt.format(
+        name=NodeName(node),
+        value=_PytreeNodeRepr(node),
+        lineno=node.lineno,
+        column=node.column,
+        prefix=repr(node.prefix))
   else:
     fmt = '{node} [{len} children] [child_indent="{indent}"]'
-    return fmt.format(node=NodeName(node),
-                      len=len(node.children),
-                      indent=GetNodeAnnotation(node, Annotation.CHILD_INDENT))
+    return fmt.format(
+        node=NodeName(node),
+        len=len(node.children),
+        indent=GetNodeAnnotation(node, Annotation.CHILD_INDENT))
 
 
 def _PytreeNodeRepr(node):
diff --git a/yapf/yapflib/reformatter.py b/yapf/yapflib/reformatter.py
index f993508..75482c5 100644
--- a/yapf/yapflib/reformatter.py
+++ b/yapf/yapflib/reformatter.py
@@ -358,9 +358,8 @@
     return count
 
   node = _StateNode(previous_node.state, newline, previous_node)
-  penalty += node.state.AddTokenToState(newline=newline,
-                                        dry_run=True,
-                                        must_split=must_split)
+  penalty += node.state.AddTokenToState(
+      newline=newline, dry_run=True, must_split=must_split)
   heapq.heappush(p_queue, _QueueItem(_OrderedPenalty(penalty, count), node))
   return count + 1
 
@@ -523,9 +522,8 @@
         if uwlines[index].lineno != uwline.lineno:
           break
         if uwline.last.value != ':':
-          leaf = pytree.Leaf(type=token.SEMI,
-                             value=';',
-                             context=('', (uwline.lineno, column)))
+          leaf = pytree.Leaf(
+              type=token.SEMI, value=';', context=('', (uwline.lineno, column)))
           uwline.AppendToken(format_token.FormatToken(leaf))
         for tok in uwlines[index].tokens:
           uwline.AppendToken(tok)
diff --git a/yapf/yapflib/split_penalty.py b/yapf/yapflib/split_penalty.py
index bffaaa6..4b802c0 100644
--- a/yapf/yapflib/split_penalty.py
+++ b/yapf/yapflib/split_penalty.py
@@ -320,8 +320,7 @@
         if node.value in {'(', 'for', 'if'}:
           return
         penalty_annotation = pytree_utils.GetNodeAnnotation(
-            node, pytree_utils.Annotation.SPLIT_PENALTY,
-            default=0)
+            node, pytree_utils.Annotation.SPLIT_PENALTY, default=0)
         if penalty_annotation < penalty:
           pytree_utils.SetNodeAnnotation(node,
                                          pytree_utils.Annotation.SPLIT_PENALTY,
@@ -347,9 +346,8 @@
   for child in tree.children:
     _RecAnnotate(child, annotate_name, annotate_value)
   if isinstance(tree, pytree.Leaf):
-    cur_annotate = pytree_utils.GetNodeAnnotation(tree,
-                                                  annotate_name,
-                                                  default=0)
+    cur_annotate = pytree_utils.GetNodeAnnotation(
+        tree, annotate_name, default=0)
     if cur_annotate < annotate_value:
       pytree_utils.SetNodeAnnotation(tree, annotate_name, annotate_value)
 
diff --git a/yapf/yapflib/subtype_assigner.py b/yapf/yapflib/subtype_assigner.py
index bcea176..4e70d61 100644
--- a/yapf/yapflib/subtype_assigner.py
+++ b/yapf/yapflib/subtype_assigner.py
@@ -231,6 +231,16 @@
     self._ProcessArgLists(node)
     self._SetDefaultOrNamedAssignArgListSubtype(node)
 
+  def Visit_funcdef(self, node):  # pylint: disable=invalid-name
+    # funcdef ::=
+    #     'def' NAME parameters ['->' test] ':' suite
+    for child in node.children:
+      if pytree_utils.NodeName(child) == 'NAME' and child.value != 'def':
+        self._AppendTokenSubtype(child, format_token.Subtype.FUNC_DEF)
+        break
+    for child in node.children:
+      self.Visit(child)
+
   def Visit_typedargslist(self, node):  # pylint: disable=invalid-name
     # typedargslist ::=
     #     ((tfpdef ['=' test] ',')*
@@ -264,10 +274,11 @@
     for child in node.children:
       self.Visit(child)
       if isinstance(child, pytree.Leaf):
-        self._AppendTokenSubtype(child,
-                                 subtype=_ARGLIST_TOKEN_TO_SUBTYPE.get(
-                                     child.value, format_token.Subtype.NONE),
-                                 force=False)
+        self._AppendTokenSubtype(
+            child,
+            subtype=_ARGLIST_TOKEN_TO_SUBTYPE.get(child.value,
+                                                  format_token.Subtype.NONE),
+            force=False)
 
   def _AppendSubtypeRec(self, node, subtype, force=True):
     """Append the leafs in the node to the given subtype."""
@@ -320,9 +331,8 @@
   first = _GetFirstLeafNode(node)
   last = _GetLastLeafNode(node)
 
-  lparen = pytree.Leaf(token.LPAR,
-                       u'(',
-                       context=('', (first.get_lineno(), first.column - 1)))
+  lparen = pytree.Leaf(
+      token.LPAR, u'(', context=('', (first.get_lineno(), first.column - 1)))
   last_lineno = last.get_lineno()
   if last.type == token.STRING and '\n' in last.value:
     last_lineno += last.value.count('\n')
@@ -331,9 +341,8 @@
     last_column = len(last.value.split('\n')[-1]) + 1
   else:
     last_column = last.column + len(last.value) + 1
-  rparen = pytree.Leaf(token.RPAR,
-                       u')',
-                       context=('', (last_lineno, last_column)))
+  rparen = pytree.Leaf(
+      token.RPAR, u')', context=('', (last_lineno, last_column)))
 
   lparen.is_pseudo = True
   rparen.is_pseudo = True
diff --git a/yapf/yapflib/unwrapped_line.py b/yapf/yapflib/unwrapped_line.py
index fafeb16..14eaa8e 100644
--- a/yapf/yapflib/unwrapped_line.py
+++ b/yapf/yapflib/unwrapped_line.py
@@ -324,9 +324,8 @@
     # reasonable assumption, because otherwise they should have written them
     # all on the same line, or with a '+'.
     return True
-  return pytree_utils.GetNodeAnnotation(cur_token.node,
-                                        pytree_utils.Annotation.MUST_SPLIT,
-                                        default=False)
+  return pytree_utils.GetNodeAnnotation(
+      cur_token.node, pytree_utils.Annotation.MUST_SPLIT, default=False)
 
 
 def _CanBreakBefore(prev_token, cur_token):
diff --git a/yapf/yapflib/yapf_api.py b/yapf/yapflib/yapf_api.py
index 3370da4..67dc72f 100644
--- a/yapf/yapflib/yapf_api.py
+++ b/yapf/yapflib/yapf_api.py
@@ -81,12 +81,13 @@
     raise ValueError('Cannot pass both in_place and print_diff.')
 
   original_source, encoding = ReadFile(filename, logger)
-  reformatted_source, changed = FormatCode(original_source,
-                                           style_config=style_config,
-                                           filename=filename,
-                                           lines=lines,
-                                           print_diff=print_diff,
-                                           verify=verify)
+  reformatted_source, changed = FormatCode(
+      original_source,
+      style_config=style_config,
+      filename=filename,
+      lines=lines,
+      print_diff=print_diff,
+      verify=verify)
   if in_place:
     if original_source and original_source != reformatted_source:
       file_resources.WriteReformattedCode(filename, reformatted_source,
@@ -138,9 +139,8 @@
   if unformatted_source == reformatted_source:
     return '' if print_diff else reformatted_source, False
 
-  code_diff = _GetUnifiedDiff(unformatted_source,
-                              reformatted_source,
-                              filename=filename)
+  code_diff = _GetUnifiedDiff(
+      unformatted_source, reformatted_source, filename=filename)
 
   if print_diff:
     return code_diff, code_diff != ''
@@ -184,9 +184,8 @@
     raise
 
   try:
-    with py3compat.open_with_encoding(filename,
-                                      mode='r',
-                                      encoding=encoding) as fd:
+    with py3compat.open_with_encoding(
+        filename, mode='r', encoding=encoding) as fd:
       source = fd.read()
     return source, encoding
   except IOError as err:  # pragma: no cover
@@ -257,10 +256,11 @@
   """
   before = before.splitlines()
   after = after.splitlines()
-  return '\n'.join(difflib.unified_diff(before,
-                                        after,
-                                        filename,
-                                        filename,
-                                        '(original)',
-                                        '(reformatted)',
-                                        lineterm='')) + '\n'
+  return '\n'.join(difflib.unified_diff(
+      before,
+      after,
+      filename,
+      filename,
+      '(original)',
+      '(reformatted)',
+      lineterm='')) + '\n'
diff --git a/yapftests/blank_line_calculator_test.py b/yapftests/blank_line_calculator_test.py
index c839ce6..7fa6a62 100644
--- a/yapftests/blank_line_calculator_test.py
+++ b/yapftests/blank_line_calculator_test.py
@@ -47,11 +47,12 @@
         else:
           msg.append(' > %s' % l)
       msg.append('Diff:')
-      msg.extend(difflib.unified_diff(code.splitlines(),
-                                      expected_code.splitlines(),
-                                      fromfile='actual',
-                                      tofile='expected',
-                                      lineterm=''))
+      msg.extend(difflib.unified_diff(
+          code.splitlines(),
+          expected_code.splitlines(),
+          fromfile='actual',
+          tofile='expected',
+          lineterm=''))
       self.fail('\n'.join(msg))
 
 
diff --git a/yapftests/file_resources_test.py b/yapftests/file_resources_test.py
index 0cf700b..3d6226d 100644
--- a/yapftests/file_resources_test.py
+++ b/yapftests/file_resources_test.py
@@ -89,13 +89,11 @@
     _touch_files([file1, file2])
 
     self.assertEqual(
-        file_resources.GetCommandLineFiles([file1, file2],
-                                           recursive=False,
-                                           exclude=None), [file1, file2])
+        file_resources.GetCommandLineFiles(
+            [file1, file2], recursive=False, exclude=None), [file1, file2])
     self.assertEqual(
-        file_resources.GetCommandLineFiles([file1, file2],
-                                           recursive=True,
-                                           exclude=None), [file1, file2])
+        file_resources.GetCommandLineFiles(
+            [file1, file2], recursive=True, exclude=None), [file1, file2])
 
   def test_nonrecursive_find_in_dir(self):
     tdir1 = self._make_test_dir('test1')
@@ -104,11 +102,12 @@
     file2 = os.path.join(tdir2, 'testfile2.py')
     _touch_files([file1, file2])
 
-    self.assertRaises(errors.YapfError,
-                      file_resources.GetCommandLineFiles,
-                      command_line_file_list=[tdir1],
-                      recursive=False,
-                      exclude=None)
+    self.assertRaises(
+        errors.YapfError,
+        file_resources.GetCommandLineFiles,
+        command_line_file_list=[tdir1],
+        recursive=False,
+        exclude=None)
 
   def test_recursive_find_in_dir(self):
     tdir1 = self._make_test_dir('test1')
@@ -120,9 +119,8 @@
     _touch_files(files)
 
     self.assertEqual(
-        sorted(file_resources.GetCommandLineFiles([self.test_tmpdir],
-                                                  recursive=True,
-                                                  exclude=None)),
+        sorted(file_resources.GetCommandLineFiles(
+            [self.test_tmpdir], recursive=True, exclude=None)),
         sorted(files))
 
   def test_recursive_find_in_dir_with_exclude(self):
@@ -135,9 +133,8 @@
     _touch_files(files)
 
     self.assertEqual(
-        sorted(file_resources.GetCommandLineFiles([self.test_tmpdir],
-                                                  recursive=True,
-                                                  exclude=['*test*3.py'])),
+        sorted(file_resources.GetCommandLineFiles(
+            [self.test_tmpdir], recursive=True, exclude=['*test*3.py'])),
         sorted([os.path.join(tdir1, 'testfile1.py'),
                 os.path.join(tdir2, 'testfile2.py')]))
 
@@ -211,10 +208,8 @@
   def test_write_to_file(self):
     s = u'foobar'
     with tempfile.NamedTemporaryFile(dir=self.test_tmpdir) as testfile:
-      file_resources.WriteReformattedCode(testfile.name,
-                                          s,
-                                          in_place=True,
-                                          encoding='utf-8')
+      file_resources.WriteReformattedCode(
+          testfile.name, s, in_place=True, encoding='utf-8')
       testfile.flush()
 
       with open(testfile.name) as f:
@@ -224,20 +219,16 @@
     s = u'foobar'
     stream = BufferedByteStream() if py3compat.PY3 else py3compat.StringIO()
     with stdout_redirector(stream):
-      file_resources.WriteReformattedCode(None,
-                                          s,
-                                          in_place=False,
-                                          encoding='utf-8')
+      file_resources.WriteReformattedCode(
+          None, s, in_place=False, encoding='utf-8')
     self.assertEqual(stream.getvalue(), s)
 
   def test_write_encoded_to_stdout(self):
     s = '\ufeff# -*- coding: utf-8 -*-\nresult = "passed"\n'  # pylint: disable=anomalous-unicode-escape-in-string
     stream = BufferedByteStream() if py3compat.PY3 else py3compat.StringIO()
     with stdout_redirector(stream):
-      file_resources.WriteReformattedCode(None,
-                                          s,
-                                          in_place=False,
-                                          encoding='utf-8')
+      file_resources.WriteReformattedCode(
+          None, s, in_place=False, encoding='utf-8')
     self.assertEqual(stream.getvalue(), s)
 
 
diff --git a/yapftests/reformatter_test.py b/yapftests/reformatter_test.py
index a8ccbb5..6f6f0dc 100644
--- a/yapftests/reformatter_test.py
+++ b/yapftests/reformatter_test.py
@@ -50,11 +50,12 @@
         else:
           msg.append(' > %s' % l)
       msg.append('Diff:')
-      msg.extend(difflib.unified_diff(code.splitlines(),
-                                      expected_code.splitlines(),
-                                      fromfile='actual',
-                                      tofile='expected',
-                                      lineterm=''))
+      msg.extend(difflib.unified_diff(
+          code.splitlines(),
+          expected_code.splitlines(),
+          fromfile='actual',
+          tofile='expected',
+          lineterm=''))
       self.fail('\n'.join(msg))
 
 
@@ -706,9 +707,10 @@
             """Common method for processing argument lists."""
             for child in node.children:
               if isinstance(child, pytree.Leaf):
-                self._SetTokenSubtype(child,
-                                      subtype=_ARGLIST_TOKEN_TO_SUBTYPE.get(
-                                          child.value, format_token.Subtype.NONE))
+                self._SetTokenSubtype(
+                    child,
+                    subtype=_ARGLIST_TOKEN_TO_SUBTYPE.get(child.value,
+                                                          format_token.Subtype.NONE))
         ''')
     uwlines = _ParseAndUnwrap(unformatted_code)
     self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@@ -1436,15 +1438,11 @@
         def f():
           if True:
             pytree_utils.InsertNodesBefore(
-                _CreateCommentsFromPrefix(comment_prefix,
-                                          comment_lineno,
-                                          comment_column,
-                                          standalone=True),
+                _CreateCommentsFromPrefix(
+                    comment_prefix, comment_lineno, comment_column, standalone=True),
                 ancestor_at_indent)
-            pytree_utils.InsertNodesBefore(_CreateCommentsFromPrefix(comment_prefix,
-                                                                     comment_lineno,
-                                                                     comment_column,
-                                                                     standalone=True))
+            pytree_utils.InsertNodesBefore(_CreateCommentsFromPrefix(
+                comment_prefix, comment_lineno, comment_column, standalone=True))
         """)
     uwlines = _ParseAndUnwrap(unformatted_code)
     self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@@ -1705,10 +1703,11 @@
               argument_name_3=3,
           )
 
-          a_very_long_function_name(long_argument_name_1=1,
-                                    long_argument_name_2=2,
-                                    long_argument_name_3=3,
-                                    long_argument_name_4=4)
+          a_very_long_function_name(
+              long_argument_name_1=1,
+              long_argument_name_2=2,
+              long_argument_name_3=3,
+              long_argument_name_4=4)
 
           a_very_long_function_name(
               long_argument_name_1,
@@ -1809,9 +1808,12 @@
     expected_formatted_code = textwrap.dedent("""\
         if True:
           query.fetch_page.assert_has_calls([
-              mock.call(100, start_cursor=None),
-              mock.call(100, start_cursor=cursor_1),
-              mock.call(100, start_cursor=cursor_2),
+              mock.call(
+                  100, start_cursor=None),
+              mock.call(
+                  100, start_cursor=cursor_1),
+              mock.call(
+                  100, start_cursor=cursor_2),
           ])
         """)
     uwlines = _ParseAndUnwrap(unformatted_code)
@@ -2089,11 +2091,12 @@
                    (1 - m.ffffffffffffffff(llllllllllllllllllllll * 1000000, m.vvv)) *
                    m.ddddddddddddddddd(m.vvv)), m.fffff(
                        m.rrr('mmmmmmmmmmmmmmmm', 'sssssssssssssssssssssss'),
-                       dict(ffffffffffffffff,
-                            **{
-                                'mmmmmm:ssssss': m.rrrrrrrrrrr('|'.join(iiiiiiiiiiiiii),
-                                                               iiiiii=True)
-                            }))
+                       dict(
+                           ffffffffffffffff,
+                           **{
+                               'mmmmmm:ssssss': m.rrrrrrrrrrr(
+                                   '|'.join(iiiiiiiiiiiiii), iiiiii=True)
+                           }))
                | m.wwwwww(m.rrrr('1h'))
                | m.ggggggg(bbbbbbbbbbbbbbb))
               | m.jjjj()
@@ -2234,10 +2237,11 @@
             if True:
               class_0_count = num_votes - class_1_count
               return ('{class_0_name}={class_0_count}, {class_1_name}={class_1_count}'
-                      .format(class_0_name=self.class_0_name,
-                              class_0_count=class_0_count,
-                              class_1_name=self.class_1_name,
-                              class_1_count=class_1_count))
+                      .format(
+                          class_0_name=self.class_0_name,
+                          class_0_count=class_0_count,
+                          class_1_name=self.class_1_name,
+                          class_1_count=class_1_count))
         """)
     uwlines = _ParseAndUnwrap(code)
     self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@@ -2245,10 +2249,10 @@
   def testB19626808(self):
     code = textwrap.dedent("""\
         if True:
-          aaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbb('ccccccccccc',
-                                            ddddddddd='eeeee').fffffffff([
-                                                ggggggggggggggggggggg
-                                            ])
+          aaaaaaaaaaaaaaaaaaaaaaa.bbbbbbbbb(
+              'ccccccccccc', ddddddddd='eeeee').fffffffff([
+                  ggggggggggggggggggggg
+              ])
         """)
     uwlines = _ParseAndUnwrap(code)
     self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@@ -2361,15 +2365,15 @@
         class Foo(object):
 
           def Bar(self):
-            aaaaa.bbbbbbb(ccc='ddddddddddddddd',
-                          eeee='ffffffffffffffffffffff-%s-%s' %
-                          (gggg, int(time.time())),
-                          hhhhhh={
-                              'iiiiiiiiiii': iiiiiiiiiii,
-                              'jjjj': jjjj.jjjjj(),
-                              'kkkkkkkkkkkk': kkkkkkkkkkkk,
-                          },
-                          llllllllll=mmmmmm.nnnnnnnnnnnnnnnn)
+            aaaaa.bbbbbbb(
+                ccc='ddddddddddddddd',
+                eeee='ffffffffffffffffffffff-%s-%s' % (gggg, int(time.time())),
+                hhhhhh={
+                    'iiiiiiiiiii': iiiiiiiiiii,
+                    'jjjj': jjjj.jjjjj(),
+                    'kkkkkkkkkkkk': kkkkkkkkkkkk,
+                },
+                llllllllll=mmmmmm.nnnnnnnnnnnnnnnn)
         """)
     uwlines = _ParseAndUnwrap(code)
     self.assertCodeEqual(code, reformatter.Reformat(uwlines))
@@ -2533,14 +2537,15 @@
         if 1:
           if 1:
             for row in AAAA:
-              self.create(aaaaaaaa="/aaa/bbbb/cccc/dddddd/eeeeeeeeeeeeeeeeeeeeeeeeee/%s"
-                          % row[0].replace(".foo", ".bar"),
-                          aaaaa=bbb[1],
-                          ccccc=bbb[2],
-                          dddd=bbb[3],
-                          eeeeeeeeeee=[s.strip() for s in bbb[4].split(",")],
-                          ffffffff=[s.strip() for s in bbb[5].split(",")],
-                          gggggg=bbb[6])
+              self.create(
+                  aaaaaaaa="/aaa/bbbb/cccc/dddddd/eeeeeeeeeeeeeeeeeeeeeeeeee/%s" %
+                  row[0].replace(".foo", ".bar"),
+                  aaaaa=bbb[1],
+                  ccccc=bbb[2],
+                  dddd=bbb[3],
+                  eeeeeeeeeee=[s.strip() for s in bbb[4].split(",")],
+                  ffffffff=[s.strip() for s in bbb[5].split(",")],
+                  gggggg=bbb[6])
         """)
     uwlines = _ParseAndUnwrap(unformatted_code)
     self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@@ -2624,11 +2629,11 @@
           if (aaaaaa.bbbbb.ccccccccccccc != ddddddd.eeeeeeeeee.fffffffffffff or
               eeeeee.fffff.ggggggggggggggggggggggggggg() !=
               hhhhhhh.iiiiiiiiii.jjjjjjjjjjjj):
-            aaaaaaaa.bbbbbbbbbbbb(aaaaaa.bbbbb.cc,
-                                  dddddddddddd=eeeeeeeeeeeeeeeeeee.fffffffffffffffff(
-                                      gggggg.hh, iiiiiiiiiiiiiiiiiii.jjjjjjjjjj.kkkkkkk,
-                                      lllll.mm),
-                                  nnnnnnnnnn=ooooooo.pppppppppp)
+            aaaaaaaa.bbbbbbbbbbbb(
+                aaaaaa.bbbbb.cc,
+                dddddddddddd=eeeeeeeeeeeeeeeeeee.fffffffffffffffff(
+                    gggggg.hh, iiiiiiiiiiiiiiiiiii.jjjjjjjjjj.kkkkkkk, lllll.mm),
+                nnnnnnnnnn=ooooooo.pppppppppp)
         """)
     uwlines = _ParseAndUnwrap(unformatted_code)
     self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@@ -2640,8 +2645,9 @@
         )
         """)
     expected_formatted_code = textwrap.dedent("""\
-        call(a=1,
-             b=2,)
+        call(
+            a=1,
+            b=2,)
         """)
     uwlines = _ParseAndUnwrap(unformatted_code)
     self.assertCodeEqual(expected_formatted_code, reformatter.Reformat(uwlines))
@@ -2908,10 +2914,8 @@
         if (aaaaaaaaaaaaaa + bbbbbbbbbbbbbbbb == ccccccccccccccccc and xxxxxxxxxxxxx or
                 yyyyyyyyyyyyyyyyy):
             pass
-        elif (xxxxxxxxxxxxxxx(aaaaaaaaaaa,
-                              bbbbbbbbbbbbbb,
-                              cccccccccccc,
-                              dddddddddd=None)):
+        elif (xxxxxxxxxxxxxxx(
+                aaaaaaaaaaa, bbbbbbbbbbbbbb, cccccccccccc, dddddddddd=None)):
             pass
 
 
@@ -3060,8 +3064,9 @@
             pass
         """)
     uwlines = _ParseAndUnwrap(unformatted_code)
-    self.assertCodeEqual(expected_formatted_code,
-                         reformatter.Reformat(uwlines, verify=False))
+    self.assertCodeEqual(
+        expected_formatted_code, reformatter.Reformat(
+            uwlines, verify=False))
 
   def testVerifyFutureImport(self):
     unformatted_code = textwrap.dedent("""\
@@ -3089,8 +3094,9 @@
             call_my_function(print)
         """)
     uwlines = _ParseAndUnwrap(unformatted_code)
-    self.assertCodeEqual(expected_formatted_code,
-                         reformatter.Reformat(uwlines, verify=False))
+    self.assertCodeEqual(
+        expected_formatted_code, reformatter.Reformat(
+            uwlines, verify=False))
 
   def testContinuationLineShouldBeDistinguished(self):
     unformatted_code = textwrap.dedent("""\
@@ -3109,8 +3115,9 @@
                     pass
         """)
     uwlines = _ParseAndUnwrap(unformatted_code)
-    self.assertCodeEqual(expected_formatted_code,
-                         reformatter.Reformat(uwlines, verify=False))
+    self.assertCodeEqual(
+        expected_formatted_code, reformatter.Reformat(
+            uwlines, verify=False))
 
 
 @unittest.skipUnless(py3compat.PY3, 'Requires Python 3')
diff --git a/yapftests/subtype_assigner_test.py b/yapftests/subtype_assigner_test.py
index 1cbbe7b..9fe5cf8 100644
--- a/yapftests/subtype_assigner_test.py
+++ b/yapftests/subtype_assigner_test.py
@@ -72,7 +72,7 @@
     uwlines = self._ParseAndUnwrap(code)
     self._CheckFormatTokenSubtypes(uwlines, [
         [('def', [format_token.Subtype.NONE]),
-         ('foo', [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}),
@@ -127,7 +127,7 @@
     uwlines = self._ParseAndUnwrap(code)
     self._CheckFormatTokenSubtypes(uwlines, [
         [('def', [format_token.Subtype.NONE]),
-         ('foo', [format_token.Subtype.NONE]),
+         ('foo', {format_token.Subtype.FUNC_DEF}),
          ('(', [format_token.Subtype.NONE]),
          ('strs', [format_token.Subtype.NONE]),
          (')', [format_token.Subtype.NONE]),
diff --git a/yapftests/yapf_test.py b/yapftests/yapf_test.py
index 2043a16..899111d 100644
--- a/yapftests/yapf_test.py
+++ b/yapftests/yapf_test.py
@@ -36,8 +36,8 @@
 class FormatCodeTest(unittest.TestCase):
 
   def _Check(self, unformatted_code, expected_formatted_code):
-    formatted_code, _ = yapf_api.FormatCode(unformatted_code,
-                                            style_config='chromium')
+    formatted_code, _ = yapf_api.FormatCode(
+        unformatted_code, style_config='chromium')
     self.assertEqual(expected_formatted_code, formatted_code)
 
   def testSimple(self):
@@ -210,9 +210,8 @@
 
         if h:    i
         """)
-    formatted_code = yapf_api.FormatFile(file1,
-                                         style_config='pep8',
-                                         lines=[(1, 2)])[0]
+    formatted_code = yapf_api.FormatFile(
+        file1, style_config='pep8', lines=[(1, 2)])[0]
     self.assertCodeEqual(expected_formatted_code_lines1and2, formatted_code)
 
     expected_formatted_code_lines3 = textwrap.dedent(u"""\
@@ -222,9 +221,8 @@
 
         if h:    i
         """)
-    formatted_code = yapf_api.FormatFile(file1,
-                                         style_config='pep8',
-                                         lines=[(3, 3)])[0]
+    formatted_code = yapf_api.FormatFile(
+        file1, style_config='pep8', lines=[(3, 3)])[0]
     self.assertCodeEqual(expected_formatted_code_lines3, formatted_code)
 
   def testFormatFileDiff(self):
@@ -245,21 +243,16 @@
     with open(file1) as f:
       self.assertCodeEqual(formatted_code, f.read())
 
-    self.assertRaises(ValueError,
-                      yapf_api.FormatFile,
-                      file1,
-                      in_place=True,
-                      print_diff=True)
+    self.assertRaises(
+        ValueError, yapf_api.FormatFile, file1, in_place=True, print_diff=True)
 
   def testNoFile(self):
     stream = py3compat.StringIO()
     handler = logging.StreamHandler(stream)
     logger = logging.getLogger('mylogger')
     logger.addHandler(handler)
-    self.assertRaises(IOError,
-                      yapf_api.FormatFile,
-                      'not_a_file.py',
-                      logger=logger.error)
+    self.assertRaises(
+        IOError, yapf_api.FormatFile, 'not_a_file.py', logger=logger.error)
     self.assertEqual(stream.getvalue(),
                      "[Errno 2] No such file or directory: 'not_a_file.py'\n")
 
@@ -338,10 +331,11 @@
       extra_options: iterable of extra command-line options to pass to yapf
     """
     cmdline = YAPF_BINARY + (extra_options or [])
-    p = subprocess.Popen(cmdline,
-                         stdout=subprocess.PIPE,
-                         stdin=subprocess.PIPE,
-                         stderr=subprocess.PIPE)
+    p = subprocess.Popen(
+        cmdline,
+        stdout=subprocess.PIPE,
+        stdin=subprocess.PIPE,
+        stderr=subprocess.PIPE)
     reformatted_code, stderrdata = p.communicate(unformatted.encode('utf-8'))
     self.assertEqual(stderrdata, b'')
     self.assertEqual(reformatted_code.decode('utf-8'), expected)
@@ -352,13 +346,13 @@
             print('⇒')
         """)
 
-    with tempfile.NamedTemporaryFile(suffix='.py',
-                                     dir=self.test_tmpdir) as outfile:
-      with tempfile.NamedTemporaryFile(suffix='.py',
-                                       dir=self.test_tmpdir) as testfile:
+    with tempfile.NamedTemporaryFile(
+        suffix='.py', dir=self.test_tmpdir) as outfile:
+      with tempfile.NamedTemporaryFile(
+          suffix='.py', dir=self.test_tmpdir) as testfile:
         testfile.write(unformatted_code.encode('UTF-8'))
-        subprocess.check_call(YAPF_BINARY + ['--diff', testfile.name],
-                              stdout=outfile)
+        subprocess.check_call(
+            YAPF_BINARY + ['--diff', testfile.name], stdout=outfile)
 
   def testInPlaceReformatting(self):
     unformatted_code = textwrap.dedent(u"""\
@@ -370,8 +364,8 @@
             x = 37
         """)
 
-    with tempfile.NamedTemporaryFile(suffix='.py',
-                                     dir=self.test_tmpdir) as testfile:
+    with tempfile.NamedTemporaryFile(
+        suffix='.py', dir=self.test_tmpdir) as testfile:
       testfile.write(unformatted_code.encode('UTF-8'))
       testfile.seek(0)
 
@@ -387,8 +381,8 @@
     unformatted_code = u'\n\n'
     expected_formatted_code = u'\n'
 
-    with tempfile.NamedTemporaryFile(suffix='.py',
-                                     dir=self.test_tmpdir) as testfile:
+    with tempfile.NamedTemporaryFile(
+        suffix='.py', dir=self.test_tmpdir) as testfile:
       testfile.write(unformatted_code.encode('UTF-8'))
       testfile.seek(0)
 
@@ -404,8 +398,8 @@
     unformatted_code = u''
     expected_formatted_code = u''
 
-    with tempfile.NamedTemporaryFile(suffix='.py',
-                                     dir=self.test_tmpdir) as testfile:
+    with tempfile.NamedTemporaryFile(
+        suffix='.py', dir=self.test_tmpdir) as testfile:
       testfile.write(unformatted_code.encode('UTF-8'))
       testfile.seek(0)
 
@@ -446,9 +440,10 @@
         def foo():  # trail
           x = 37
         """)
-    self.assertYapfReformats(unformatted_code,
-                             expected_formatted_code,
-                             extra_options=['--style=chromium'])
+    self.assertYapfReformats(
+        unformatted_code,
+        expected_formatted_code,
+        extra_options=['--style=chromium'])
 
   def testSetCustomStyleBasedOnChromium(self):
     unformatted_code = textwrap.dedent(u"""\
@@ -467,9 +462,10 @@
           SPACES_BEFORE_COMMENT = 4
           '''))
       f.flush()
-      self.assertYapfReformats(unformatted_code,
-                               expected_formatted_code,
-                               extra_options=['--style={0}'.format(f.name)])
+      self.assertYapfReformats(
+          unformatted_code,
+          expected_formatted_code,
+          extra_options=['--style={0}'.format(f.name)])
 
   def testReadSingleLineCodeFromStdin(self):
     unformatted_code = textwrap.dedent(u"""\
@@ -488,13 +484,13 @@
             x = 37
         """)
 
-    with tempfile.NamedTemporaryFile(suffix='.py',
-                                     dir=self.test_tmpdir) as outfile:
-      with tempfile.NamedTemporaryFile(suffix='.py',
-                                       dir=self.test_tmpdir) as testfile:
+    with tempfile.NamedTemporaryFile(
+        suffix='.py', dir=self.test_tmpdir) as outfile:
+      with tempfile.NamedTemporaryFile(
+          suffix='.py', dir=self.test_tmpdir) as testfile:
         testfile.write(unformatted_code.encode('utf-8'))
-        subprocess.check_call(YAPF_BINARY + ['--diff', testfile.name],
-                              stdout=outfile)
+        subprocess.check_call(
+            YAPF_BINARY + ['--diff', testfile.name], stdout=outfile)
 
   def testReformattingSpecificLines(self):
     unformatted_code = textwrap.dedent(u"""\
@@ -521,9 +517,10 @@
     # TODO(ambv): the `expected_formatted_code` here is not PEP8 compliant,
     # raising "E129 visually indented line with same indent as next logical
     # line" with flake8.
-    self.assertYapfReformats(unformatted_code,
-                             expected_formatted_code,
-                             extra_options=['--lines', '1-2'])
+    self.assertYapfReformats(
+        unformatted_code,
+        expected_formatted_code,
+        extra_options=['--lines', '1-2'])
 
   def testReformattingSkippingLines(self):
     unformatted_code = textwrap.dedent(u"""\
@@ -693,9 +690,10 @@
 
                 pass
         """)
-    self.assertYapfReformats(unformatted_code,
-                             expected_formatted_code,
-                             extra_options=['--lines', '1-2'])
+    self.assertYapfReformats(
+        unformatted_code,
+        expected_formatted_code,
+        extra_options=['--lines', '1-2'])
 
     unformatted_code = textwrap.dedent(u"""\
 
@@ -743,9 +741,8 @@
         import blah
         """)
 
-    self.assertYapfReformats(unformatted_code,
-                             unformatted_code,
-                             extra_options=['--lines', '2-2'])
+    self.assertYapfReformats(
+        unformatted_code, unformatted_code, extra_options=['--lines', '2-2'])
 
   def testRetainingSemicolonsWhenSpecifyingLines(self):
     unformatted_code = textwrap.dedent("""\
@@ -760,9 +757,10 @@
             x = y + 42; z = n * 42
             if True: a += 1 ; b += 1 ; c += 1
         """)
-    self.assertYapfReformats(unformatted_code,
-                             expected_formatted_code,
-                             extra_options=['--lines', '1-1'])
+    self.assertYapfReformats(
+        unformatted_code,
+        expected_formatted_code,
+        extra_options=['--lines', '1-1'])
 
   def testDisabledMultilineStrings(self):
     unformatted_code = textwrap.dedent('''\
@@ -785,9 +783,10 @@
         </body>
         </html>"""
         ''')
-    self.assertYapfReformats(unformatted_code,
-                             expected_formatted_code,
-                             extra_options=['--lines', '1-1'])
+    self.assertYapfReformats(
+        unformatted_code,
+        expected_formatted_code,
+        extra_options=['--lines', '1-1'])
 
   def testDisableWhenSpecifyingLines(self):
     unformatted_code = textwrap.dedent(u"""\
@@ -814,9 +813,10 @@
             'world',
         ])  # yapf: disable
         """)
-    self.assertYapfReformats(unformatted_code,
-                             expected_formatted_code,
-                             extra_options=['--lines', '1-10'])
+    self.assertYapfReformats(
+        unformatted_code,
+        expected_formatted_code,
+        extra_options=['--lines', '1-10'])
 
   def testDisableFormattingInDataLiteral(self):
     unformatted_code = textwrap.dedent(u"""\
@@ -853,9 +853,10 @@
             why_would_you()
             ['do', 'that']
         """)
-    self.assertYapfReformats(unformatted_code,
-                             expected_formatted_code,
-                             extra_options=['--lines', '14-15'])
+    self.assertYapfReformats(
+        unformatted_code,
+        expected_formatted_code,
+        extra_options=['--lines', '14-15'])
 
   def testRetainVerticalFormattingBetweenDisabledAndEnabledLines(self):
     unformatted_code = textwrap.dedent(u"""\
@@ -878,9 +879,10 @@
                                  gggggggggggg.hhhhhhhhh(c, c.ffffffffffff))
                 iiiii = jjjjjjjjjjjjjj.iiiii
         """)
-    self.assertYapfReformats(unformatted_code,
-                             expected_formatted_code,
-                             extra_options=['--lines', '4-7'])
+    self.assertYapfReformats(
+        unformatted_code,
+        expected_formatted_code,
+        extra_options=['--lines', '4-7'])
 
   def testFormatLinesSpecifiedInMiddleOfExpression(self):
     unformatted_code = textwrap.dedent(u"""\
@@ -903,9 +905,10 @@
                                  gggggggggggg.hhhhhhhhh(c, c.ffffffffffff))
                 iiiii = jjjjjjjjjjjjjj.iiiii
         """)
-    self.assertYapfReformats(unformatted_code,
-                             expected_formatted_code,
-                             extra_options=['--lines', '5-6'])
+    self.assertYapfReformats(
+        unformatted_code,
+        expected_formatted_code,
+        extra_options=['--lines', '5-6'])
 
   def testCommentFollowingMultilineString(self):
     unformatted_code = textwrap.dedent(u"""\
@@ -924,9 +927,10 @@
             x = '''hello world'''  # second comment
             return 42  # another comment
         """)
-    self.assertYapfReformats(unformatted_code,
-                             expected_formatted_code,
-                             extra_options=['--lines', '1-1'])
+    self.assertYapfReformats(
+        unformatted_code,
+        expected_formatted_code,
+        extra_options=['--lines', '1-1'])
 
   def testDedentClosingBracket(self):
     # no line-break on the first argument, not dedenting closing brackets
@@ -940,9 +944,10 @@
                                     second_argument_makes_the_line_too_long):
           pass
     """)
-    self.assertYapfReformats(unformatted_code,
-                             expected_formatted_code,
-                             extra_options=['--style=pep8'])
+    self.assertYapfReformats(
+        unformatted_code,
+        expected_formatted_code,
+        extra_options=['--style=pep8'])
 
     # TODO(ambv): currently the following produces the closing bracket on a new
     # line but indented to the opening bracket which is the worst of both
@@ -970,9 +975,10 @@
       ):
           pass
     """)
-    self.assertYapfReformats(unformatted_code,
-                             expected_formatted_fb_code,
-                             extra_options=['--style=facebook'])
+    self.assertYapfReformats(
+        unformatted_code,
+        expected_formatted_fb_code,
+        extra_options=['--style=facebook'])
     # TODO(ambv): currently the following produces code that is not PEP8
     # compliant, raising "E125 continuation line with same indent as next
     # logical line" with flake8. Expected behaviour for PEP8 would be to use
@@ -1000,9 +1006,10 @@
           coalesce_brackets = True
           '''))
       f.flush()
-      self.assertYapfReformats(unformatted_code,
-                               expected_formatted_code,
-                               extra_options=['--style={0}'.format(f.name)])
+      self.assertYapfReformats(
+          unformatted_code,
+          expected_formatted_code,
+          extra_options=['--style={0}'.format(f.name)])
 
   def testPseudoParenSpaces(self):
     unformatted_code = textwrap.dedent(u"""\
@@ -1015,10 +1022,10 @@
           def bar():
             return {msg_id: author for author, msg_id in reader}
         """)
-    self.assertYapfReformats(unformatted_code,
-                             expected_formatted_code,
-                             extra_options=['--lines', '1-1', '--style',
-                                            'chromium'])
+    self.assertYapfReformats(
+        unformatted_code,
+        expected_formatted_code,
+        extra_options=['--lines', '1-1', '--style', 'chromium'])
 
   def testMultilineCommentFormattingDisabled(self):
     unformatted_code = textwrap.dedent(u"""\
@@ -1049,10 +1056,10 @@
             '#': lambda x: x  # do nothing
         }
         """)
-    self.assertYapfReformats(unformatted_code,
-                             expected_formatted_code,
-                             extra_options=['--lines', '1-1', '--style',
-                                            'chromium'])
+    self.assertYapfReformats(
+        unformatted_code,
+        expected_formatted_code,
+        extra_options=['--lines', '1-1', '--style', 'chromium'])
 
   def testTrailingCommentsWithDisabledFormatting(self):
     unformatted_code = textwrap.dedent(u"""\
@@ -1069,10 +1076,10 @@
             'hello world'  # This is a comment.
         ]
         """)
-    self.assertYapfReformats(unformatted_code,
-                             expected_formatted_code,
-                             extra_options=['--lines', '1-1', '--style',
-                                            'chromium'])
+    self.assertYapfReformats(
+        unformatted_code,
+        expected_formatted_code,
+        extra_options=['--lines', '1-1', '--style', 'chromium'])
 
   def testUseTabs(self):
     unformatted_code = textwrap.dedent(u"""\
@@ -1093,9 +1100,10 @@
           INDENT_WIDTH=1
           '''))
       f.flush()
-      self.assertYapfReformats(unformatted_code,
-                               expected_formatted_code,
-                               extra_options=['--style={0}'.format(f.name)])
+      self.assertYapfReformats(
+          unformatted_code,
+          expected_formatted_code,
+          extra_options=['--style={0}'.format(f.name)])
 
 
 class BadInputTest(unittest.TestCase):