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

converting f-strings to normal strings, contents are not correctly preserved f'{{test}}' == '{test}' != '{{test}}' #2936

Closed
OliverTED opened this issue Feb 15, 2023 · 2 comments · Fixed by #2971
Labels
bug Something isn't working

Comments

@OliverTED
Copy link

The f-string f"{{test}}" without a variable, it is automatically converted to "{{test}}".

But they are not the same. (See: https://peps.python.org/pep-0498/#escape-sequences ; e.g. f'{{ {4*10} }}' == '{ 40 }')

Expected: f"{{test}}" -> "{test}"

BTW, Thanks for ruff ... !

@charliermarsh charliermarsh added the bug Something isn't working label Feb 15, 2023
@charliermarsh
Copy link
Member

Thanks for filing!

@charliermarsh
Copy link
Member

(Confirmed, the autofix here just removes the prefix, but doesn't un-escape any curly contents.)

sbrugman added a commit to sbrugman/ruff that referenced this issue Feb 16, 2023
sbrugman added a commit to sbrugman/ruff that referenced this issue Feb 16, 2023
sbrugman added a commit to sbrugman/ruff that referenced this issue Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants