Ignore quote escapes in expression part of f-string#7597
Merged
dhruvmanila merged 3 commits intodhruv/pep-701from Sep 25, 2023
Merged
Ignore quote escapes in expression part of f-string#7597dhruvmanila merged 3 commits intodhruv/pep-701from
dhruvmanila merged 3 commits intodhruv/pep-701from
Conversation
This was referenced Sep 22, 2023
Member
Author
This was referenced Sep 22, 2023
0fa1e61 to
e357be1
Compare
charliermarsh
approved these changes
Sep 22, 2023
MichaReiser
reviewed
Sep 22, 2023
MichaReiser
approved these changes
Sep 25, 2023
dhruvmanila
added a commit
that referenced
this pull request
Sep 26, 2023
## Summary This PR fixes the following issues w.r.t. the PEP 701 changes: 1. Mark all unformatted comments inside f-strings as formatted only _after_ the f-string has been formatted. 2. Do not escape or remove the quote escape when normalizing the expression part of a f-string. This PR also updates the `--files-with-errors` number to be 1 less. This is because we can now parse the [`test_fstring.py`](https://discord.com/channels/1039017663004942429/1082324263199064206/1154633274887516254) file in the CPython repository which contains the new f-string syntax. This is also the file which updates the similarity index for CPython compared to main. ## Test Plan `cargo test -p ruff_python_formatter` ### Ecosystem checks #### `dhruv/formatter-fstring-quote` | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76051 | 1789 | 1632 | | django | 0.99983 | 2760 | 36 | | transformers | 0.99963 | 2587 | 323 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99979 | 3496 | 22 | | warehouse | 0.99967 | 648 | 15 | | zulip | 0.99972 | 1437 | 21 | #### `main` | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76083 | 1789 | 1631 | | django | 0.99983 | 2760 | 36 | | transformers | 0.99963 | 2587 | 323 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99979 | 3496 | 22 | | warehouse | 0.99967 | 648 | 15 | | zulip | 0.99972 | 1437 | 21 |
dhruvmanila
added a commit
that referenced
this pull request
Sep 27, 2023
## Summary This PR fixes the following issues w.r.t. the PEP 701 changes: 1. Mark all unformatted comments inside f-strings as formatted only _after_ the f-string has been formatted. 2. Do not escape or remove the quote escape when normalizing the expression part of a f-string. This PR also updates the `--files-with-errors` number to be 1 less. This is because we can now parse the [`test_fstring.py`](https://discord.com/channels/1039017663004942429/1082324263199064206/1154633274887516254) file in the CPython repository which contains the new f-string syntax. This is also the file which updates the similarity index for CPython compared to main. ## Test Plan `cargo test -p ruff_python_formatter` ### Ecosystem checks #### `dhruv/formatter-fstring-quote` | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76051 | 1789 | 1632 | | django | 0.99983 | 2760 | 36 | | transformers | 0.99963 | 2587 | 323 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99979 | 3496 | 22 | | warehouse | 0.99967 | 648 | 15 | | zulip | 0.99972 | 1437 | 21 | #### `main` | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76083 | 1789 | 1631 | | django | 0.99983 | 2760 | 36 | | transformers | 0.99963 | 2587 | 323 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99979 | 3496 | 22 | | warehouse | 0.99967 | 648 | 15 | | zulip | 0.99972 | 1437 | 21 |
dhruvmanila
added a commit
that referenced
this pull request
Sep 28, 2023
## Summary This PR fixes the following issues w.r.t. the PEP 701 changes: 1. Mark all unformatted comments inside f-strings as formatted only _after_ the f-string has been formatted. 2. Do not escape or remove the quote escape when normalizing the expression part of a f-string. This PR also updates the `--files-with-errors` number to be 1 less. This is because we can now parse the [`test_fstring.py`](https://discord.com/channels/1039017663004942429/1082324263199064206/1154633274887516254) file in the CPython repository which contains the new f-string syntax. This is also the file which updates the similarity index for CPython compared to main. ## Test Plan `cargo test -p ruff_python_formatter` ### Ecosystem checks #### `dhruv/formatter-fstring-quote` | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76051 | 1789 | 1632 | | django | 0.99983 | 2760 | 36 | | transformers | 0.99963 | 2587 | 323 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99979 | 3496 | 22 | | warehouse | 0.99967 | 648 | 15 | | zulip | 0.99972 | 1437 | 21 | #### `main` | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76083 | 1789 | 1631 | | django | 0.99983 | 2760 | 36 | | transformers | 0.99963 | 2587 | 323 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99979 | 3496 | 22 | | warehouse | 0.99967 | 648 | 15 | | zulip | 0.99972 | 1437 | 21 |
dhruvmanila
added a commit
that referenced
this pull request
Sep 29, 2023
This PR fixes the following issues w.r.t. the PEP 701 changes: 1. Mark all unformatted comments inside f-strings as formatted only _after_ the f-string has been formatted. 2. Do not escape or remove the quote escape when normalizing the expression part of a f-string. This PR also updates the `--files-with-errors` number to be 1 less. This is because we can now parse the [`test_fstring.py`](https://discord.com/channels/1039017663004942429/1082324263199064206/1154633274887516254) file in the CPython repository which contains the new f-string syntax. This is also the file which updates the similarity index for CPython compared to main. `cargo test -p ruff_python_formatter` | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76051 | 1789 | 1632 | | django | 0.99983 | 2760 | 36 | | transformers | 0.99963 | 2587 | 323 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99979 | 3496 | 22 | | warehouse | 0.99967 | 648 | 15 | | zulip | 0.99972 | 1437 | 21 | | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76083 | 1789 | 1631 | | django | 0.99983 | 2760 | 36 | | transformers | 0.99963 | 2587 | 323 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99979 | 3496 | 22 | | warehouse | 0.99967 | 648 | 15 | | zulip | 0.99972 | 1437 | 21 |
dhruvmanila
added a commit
that referenced
this pull request
Sep 29, 2023
This PR fixes the following issues w.r.t. the PEP 701 changes: 1. Mark all unformatted comments inside f-strings as formatted only _after_ the f-string has been formatted. 2. Do not escape or remove the quote escape when normalizing the expression part of a f-string. This PR also updates the `--files-with-errors` number to be 1 less. This is because we can now parse the [`test_fstring.py`](https://discord.com/channels/1039017663004942429/1082324263199064206/1154633274887516254) file in the CPython repository which contains the new f-string syntax. This is also the file which updates the similarity index for CPython compared to main. `cargo test -p ruff_python_formatter` | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76051 | 1789 | 1632 | | django | 0.99983 | 2760 | 36 | | transformers | 0.99963 | 2587 | 323 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99979 | 3496 | 22 | | warehouse | 0.99967 | 648 | 15 | | zulip | 0.99972 | 1437 | 21 | | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76083 | 1789 | 1631 | | django | 0.99983 | 2760 | 36 | | transformers | 0.99963 | 2587 | 323 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99979 | 3496 | 22 | | warehouse | 0.99967 | 648 | 15 | | zulip | 0.99972 | 1437 | 21 |
dhruvmanila
added a commit
that referenced
this pull request
Sep 29, 2023
## Summary This PR adds support for PEP 701 in Ruff. This is a rollup PR of all the other individual PRs. The separate PRs were created for logic separation and code reviews. Refer to each pull request for a detail description on the change. Refer to the PR description for the list of pull requests within this PR. ## Test Plan ### Formatter ecosystem checks Explanation for the change in ecosystem check: #7597 (comment) #### `main` ``` | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76083 | 1789 | 1631 | | django | 0.99983 | 2760 | 36 | | transformers | 0.99963 | 2587 | 319 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99983 | 3496 | 18 | | warehouse | 0.99967 | 648 | 15 | | zulip | 0.99972 | 1437 | 21 | ``` #### `dhruv/pep-701` ``` | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76051 | 1789 | 1632 | | django | 0.99983 | 2760 | 36 | | transformers | 0.99963 | 2587 | 319 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99983 | 3496 | 18 | | warehouse | 0.99967 | 648 | 15 | | zulip | 0.99972 | 1437 | 21 | ```
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.

Summary
This PR fixes the following issues w.r.t. the PEP 701 changes:
f-string has been formatted.
part of a f-string.
This PR also updates the
--files-with-errorsnumber to be 1 less. This isbecause we can now parse the
test_fstring.pyfile in the CPython repository which contains the new f-string syntax. This is
also the file which updates the similarity index for CPython compared to main.
Test Plan
cargo test -p ruff_python_formatterEcosystem checks
dhruv/formatter-fstring-quotemain