Repository: asottile/add-trailing-comma

Issue:
Blank lines may be considered as "minimum" indentation while unhugging
They should be ignored, this currently introduces trailing whitespace:

```python
x('foo', (
    'bar',

    'baz',
))
```

Discussion:

Patch:
diff --git a/add_trailing_comma.py b/add_trailing_comma.py
index 0f86212..2884adf 100644
--- a/add_trailing_comma.py
+++ b/add_trailing_comma.py
@@ -271,7 +271,7 @@ def _fix_brace(fix_data, add_comma, tokens):
         indents = []
         insert_indents = []
         for i in range(first_brace + 3, last_brace):
-            if tokens[i - 1].name == 'NL':
+            if tokens[i - 1].name == 'NL' and tokens[i].name != 'NL':
                 if tokens[i].name != UNIMPORTANT_WS:
                     min_indent = 0
                     insert_indents.append(i)


Test patch:
diff --git a/tests/add_trailing_comma_test.py b/tests/add_trailing_comma_test.py
index b8b6f73..1cd26c9 100644
--- a/tests/add_trailing_comma_test.py
+++ b/tests/add_trailing_comma_test.py
@@ -473,6 +473,22 @@ def test_noop_unhugs(src):
             '    "bar"\n'
             ')',
         ),
+        # Regression test for #17
+        (
+            'x("foo", (\n'
+            '    "bar",\n'
+            '\n'
+            '    "baz",\n'
+            '))',
+
+            'x(\n'
+            '    "foo", (\n'
+            '        "bar",\n'
+            '\n'
+            '        "baz",\n'
+            '    ),\n'
+            ')',
+        ),
     ),
 )
 def test_fix_unhugs(src, expected):