Update UP032 to unescape curly braces in literal parts of converted strings#8697
Merged
Update UP032 to unescape curly braces in literal parts of converted strings#8697
Conversation
53febeb to
5d3e19b
Compare
zanieb
commented
Nov 15, 2023
...f_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_0.py.snap
Outdated
Show resolved
Hide resolved
Contributor
|
charliermarsh
approved these changes
Nov 15, 2023
84f293a to
59791aa
Compare
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8694