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

Update UP032 to unescape curly braces in literal parts of converted strings #8697

Merged
merged 2 commits into from
Nov 16, 2023

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Nov 15, 2023

Closes #8694

@zanieb zanieb changed the title Add failing test case for escaped curly braces bug in UP032 Update UP032 to unescape curly braces in literal parts of converted strings Nov 15, 2023
@zanieb zanieb added the bug Something isn't working label Nov 15, 2023
Copy link
Contributor

github-actions bot commented Nov 15, 2023

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@zanieb zanieb marked this pull request as ready for review November 15, 2023 17:29
@zanieb zanieb merged commit d1e88dc into main Nov 16, 2023
17 checks passed
@zanieb zanieb deleted the zanie/up032-curly-escape branch November 16, 2023 19:59
dhruvmanila added a commit that referenced this pull request May 27, 2024
## Summary

This PR brings back the functionality to remove empty strings when
converting to an f-string in `UP032`.

For context, #8712 added this
functionality to remove _trailing_ empty strings but it got removed in
#8697 possibly unexpectedly so.

There's one difference which is that this PR will remove _any_ empty
strings and not just trailing ones. For example,

```diff
--- /Users/dhruv/playground/ruff/src/UP032.py
+++ /Users/dhruv/playground/ruff/src/UP032.py
@@ -1,7 +1,5 @@
 (
-    "{a}"
-    ""
-    "{b}"
-    ""
-).format(a=1, b=1)
+    f"{1}"
+    f"{1}"
+)
```

## Test Plan

Run `cargo insta test` and update the snapshots.
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 this pull request may close these issues.

UP032 does not cleanup escaped format placeholders in string continuations
2 participants