Repository: asottile/yesqa

Issue:
yesqa turns `# noqa: F821,E501` into `# noqa: F821`, but then flake8 reports it
Here's an example:
```console
$ cat t.py 
def foo(w: Sequence[int], x: Sequence[int], y: int, z: int) -> bar: ...  # noqa: F821,E501
$ yesqa t.py 
Rewriting t.py
$ cat t.py 
def foo(w: Sequence[int], x: Sequence[int], y: int, z: int) -> bar: ...  # noqa: F821
$ flake8 t.py 
t.py:1:80: E501 line too long (85 > 79 characters)
```

Discussion:

Patch:
diff --git a/yesqa.py b/yesqa.py
index 18ad40f..a0a49eb 100644
--- a/yesqa.py
+++ b/yesqa.py
@@ -7,6 +7,7 @@ import sys
 import tempfile
 from typing import Dict
 from typing import List
+from typing import Match
 from typing import Optional
 from typing import Sequence
 from typing import Set
@@ -49,12 +50,24 @@ def _remove_comments(tokens: Tokens) -> Tokens:
     for i, token in tokenize_rt.reversed_enumerate(tokens):
         if token.name == 'COMMENT':
             if NOQA_RE.search(token.src):
-                _rewrite_noqa_comment(tokens, i, collections.defaultdict(set))
+                _mask_noqa_comment(tokens, i)
             elif NOQA_FILE_RE.search(token.src):
                 _remove_comment(tokens, i)
     return tokens
 
 
+def _mask_noqa_comment(tokens: Tokens, i: int) -> None:
+    token = tokens[i]
+    match = NOQA_RE.search(token.src)
+    assert match is not None
+
+    def _sub(match: Match[str]) -> str:
+        return f'# {"."*(len(match.group())-2)}'
+
+    src = NOQA_RE.sub(_sub, token.src)
+    tokens[i] = token._replace(src=src)
+
+
 def _rewrite_noqa_comment(
         tokens: Tokens,
         i: int,


Test patch:
diff --git a/tests/yesqa_test.py b/tests/yesqa_test.py
index 75d1081..b1cb7ef 100644
--- a/tests/yesqa_test.py
+++ b/tests/yesqa_test.py
@@ -45,6 +45,8 @@ def test_non_utf8_bytes(tmpdir, capsys):
         'def f():\n'
         '    # type: () -> ' + 'A' * 65 + '  # noqa\n'
         '    pass\n',
+        'def foo(w: Sequence[int], x: Sequence[int], y: int, z: int) -> bar: ...  # noqa: E501, F821\n',
+        'def foo(w: Sequence[int]) -> bar:  # foobarfoobarfoobarfoobarfoobarfoo   # noqa: E501, F821\n',
     ),
 )
 def test_ok(assert_rewrite, src):