Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyupgrade 3.16.0 improperly breaks on emoji/formatted multiline string #949

Closed
hemanthkini opened this issue Jun 12, 2024 · 2 comments
Closed

Comments

@hemanthkini
Copy link

Using Python 3.12.4 and pyupgrade 3.16.0 results in a bug:

hkini$ pip show pyupgrade
Name: pyupgrade
Version: 3.16.0
Summary: A tool to automatically upgrade syntax for newer versions.
Home-page: https://github.com/asottile/pyupgrade
Author: Anthony Sottile
Author-email: asottile@umich.edu
License: MIT
Location: /Users/hkini/.asdf/installs/python/3.12.4/lib/python3.12/site-packages
Requires: tokenize-rt
Required-by:
hkini$ cat test.py
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
hkini$ pyupgrade test.py
Rewriting test.py
hkini$ cat test.py
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 {te{test_arg1} </td>
        </tr>
    </table>
    """
    return content

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.

@hemanthkini
Copy link
Author

Note - I think this relates to PyCQA/docformatter#282 (which I also filed)

@asottile
Copy link
Owner

please make an issue against cpython, they must have regressed fstring positions again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants