-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary This PR is a small refactor to extract out the logic for normalizing string in the formatter from the `StringPart` struct. It also separates the quote selection into a separate method on the new `StringNormalizer`. Both of these will help in the f-string formatting to use `StringPart` and `choose_quotes` irrespective of normalization. The reason for having separate quote selection and normalization step is so that the f-string formatting can perform quote selection on its own. Unlike string and byte literals, the f-string formatting would require that the normalization happens only for the literal elements of it i.e., the "foo" and "bar" in `f"foo {x + y} bar"`. This will automatically be handled by the already separate `normalize_string` function. Another use-case in the f-string formatting is to extract out the relevant information from the `StringPart` like quotes and prefix which is to be passed as context while formatting each element of an f-string. ## Test Plan Ensure that clippy is happy and all tests pass.
- Loading branch information
1 parent
6380c90
commit 6f9c128
Showing
4 changed files
with
96 additions
and
59 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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