Repository: PyCQA/docformatter (python)

Issue:
Blank line removal incompatible with black
If a class docstring contains a line that is too long and cannot be reformatted, passing flake8 can be done by appending a `#noqa` to the docstring.
The following was not modified with` docformatter` 1.5.1 and `black` when triggered by `pre-commit`:
```python
class C:
    """Class.""" #noqa

    attr: int
    """Attr."""
```

With `docformatter` 1.6.1, this is changed to:
```python
class C:
    """Class.""" #noqa
    attr: int
    """Attr."""
```

and `pre-commit` always fails because `docformatter` and `black` both apply opposite changes.

This behavior is triggered by the comment appended to the docstring.

Pull request description:
fix: remove blank after comment
Fixes problem with docformatter removing the blank following a class docstring when the docstring is followed by a comment.

Closes #176.

Patch:
diff --git a/src/docformatter/format.py b/src/docformatter/format.py
index d846361..d8bbbb9 100644
--- a/src/docformatter/format.py
+++ b/src/docformatter/format.py
@@ -29,6 +29,7 @@ import argparse
 import collections
 import contextlib
 import io
+import re
 import tokenize
 from typing import TextIO, Tuple
 
@@ -587,11 +588,15 @@ class Formatter:
                 ].strip().startswith(
                     '"""'
                 )
+                _comment_follows = re.search(
+                    r"\"\"\" *#", modified_tokens[_idx - 4][4]
+                )
 
                 if (
                     _token[0] == 1
                     and not _is_definition
                     and not _is_docstring
+                    and not _comment_follows
                     and _after_definition
                     and _after_docstring
                 ):


Test patch:
diff --git a/tests/test_format_docstring.py b/tests/test_format_docstring.py
index bfc2f6a..e4cdfe4 100644
--- a/tests/test_format_docstring.py
+++ b/tests/test_format_docstring.py
@@ -366,6 +366,49 @@ class AcceptLanguageHeader(ExtendedSchemaNode): \
     # FIXME: oneOf validator for supported languages (?)'
         assert docstring == uut._do_format_code(docstring)
 
+    @pytest.mark.unit
+    @pytest.mark.parametrize("args", [[""]])
+    def test_format_docstring_leave_blank_line_after_comment(self,
+                                                                  test_args,
+                                                                  args,):
+        """Leave blank lines after docstring followed by a comment.
+
+        See issue #176.
+        """
+        uut = Formatter(
+            test_args,
+            sys.stderr,
+            sys.stdin,
+            sys.stdout,
+        )
+
+        docstring = '''\
+def Class1:
+    """Class.""" #noqa
+
+    attribute
+    """Attr."""
+
+
+def Class2:
+    """Class."""
+
+    attribute
+    """Attr."""
+
+
+def Class3:
+    """Class docstring.
+
+    With long description.
+    """    #noqa
+
+    attribute
+    """Attr."""
+'''
+        assert docstring == uut._do_format_code(docstring)
+
+
 class TestFormatLists:
     """Class for testing format_docstring() with lists in the docstring."""