PyCQA / docformatter

Formats docstrings to follow PEP 257
https://pypi.python.org/pypi/docformatter
MIT License
530 stars 61 forks source link

docformatter 1.7.5 improperly breaks on emoji/formatted multiline string #282

Open hemanthkini opened 3 months ago

hemanthkini commented 3 months ago

Running docformatter 1.7.5 with Python 3.12.4 against this test file:

def test(test_arg1):
    content = f"""
    <table style="width: 100%; height: 100%; font-size: 1.1em;">
        <tr>
            <td style="width: 100%; height: 100%;">🔗 This is a test {test_arg1} </td>
        </tr>
    </table>
    """
    return content

improperly returns:

--- before/test.py
+++ after/test.py
@@ -2,7 +2,7 @@
     content = f"""
     <table style="width: 100%; height: 100%; font-size: 1.1em;">
         <tr>
-            <td style="width: 100%; height: 100%;">🔗 This is a test {test_arg1} </td>
+            <td style="width: 100%; height: 100%;">🔗 This is a test {te{test_arg1} </td>
         </tr>
     </table>
     """

This used to work with Python 3.12.2 - I suspect it's a combination of the use of an emoji, the variable within the curly brace, and some change in the tokenizer/untokenizer logic.