code: def add_parens(line, maxline, indent, statements=statements, count=count):
      
  
      if line[0] in statements:
          index = 1
          if not line[0].endswith(' '):
              index = 2
              assert line[1] == ' '
          line.insert(index, '(')
          if line[-1] == ':':
              line.insert(-1, ')')
          else:
              line.append(')')
  
      # That was the easy stuff.  Now for assignments.
      groups = list(get_assign_groups(line))
      if len(groups) == 1:
          # So sad, too bad
          return line
  
      counts = list(count(x) for x in groups)
      didwrap = False
  
      # If the LHS is large, wrap it first
      if sum(counts[:-1]) >= maxline - indent - 4:
          for group in groups[:-1]:
              didwrap = False  # Only want to know about last group
              if len(group) > 1:
                  group.insert(0, '(')
                  group.insert(-1, ')')
                  didwrap = True
  
      # Might not need to wrap the RHS if wrapped the LHS
      if not didwrap or counts[-1] > maxline - indent - 10:
          groups[-1].insert(0, '(')
          groups[-1].append(')')
  
      return [item for group in groups for item in group]
docs: Attempt to add parentheses around the line
         in order to make it splittable.