Use reserved width to include line suffix measurement#6901
Merged
MichaReiser merged 11 commits intoastral-sh:mainfrom Aug 30, 2023
Merged
Use reserved width to include line suffix measurement#6901MichaReiser merged 11 commits intoastral-sh:mainfrom
MichaReiser merged 11 commits intoastral-sh:mainfrom
Conversation
CodSpeed Performance ReportMerging #6901 will not alter performanceComparing Summary
|
45d5cc2 to
4e3783f
Compare
MichaReiser
requested changes
Aug 27, 2023
Member
MichaReiser
left a comment
There was a problem hiding this comment.
Looks good overall but we need to ensure that the comment written by format_comment and the width measured by measure_text match.
4e3783f to
64ee0d6
Compare
64ee0d6 to
cfe9587
Compare
e500d39 to
cd97445
Compare
cd97445 to
a4d21fd
Compare
bccc124 to
0c0a43c
Compare
cnpryer
commented
Aug 27, 2023
MichaReiser
requested changes
Aug 28, 2023
b83d72b to
15ebfaf
Compare
cnpryer
commented
Aug 28, 2023
cnpryer
commented
Aug 28, 2023
15ebfaf to
3c210c4
Compare
cnpryer
commented
Aug 29, 2023
cc74835 to
0aa3a86
Compare
MichaReiser
reviewed
Aug 29, 2023
MichaReiser
reviewed
Aug 29, 2023
304b606 to
caf0aae
Compare
caf0aae to
ba678b1
Compare
cnpryer
commented
Aug 29, 2023
cnpryer
commented
Aug 29, 2023
cnpryer
commented
Aug 29, 2023
cnpryer
commented
Aug 29, 2023
crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/tuple.py
Outdated
Show resolved
Hide resolved
b050c9d to
1745d3d
Compare
c8f4514 to
16f6617
Compare
MichaReiser
approved these changes
Aug 30, 2023
Member
MichaReiser
left a comment
There was a problem hiding this comment.
Nice. This greatly improves our black compatibility!
This PR
| project | similarity index | total files | changed files |
|---|---|---|---|
| cpython | 0.76079 | 1789 | 1635 |
| django | 0.99948 | 2760 | 85 |
| transformers | 0.99925 | 2587 | 495 |
| twine | 0.99965 | 33 | 3 |
| typeshed | 0.99947 | 3496 | 2173 |
| warehouse | 0.99659 | 648 | 41 |
| zulip | 0.99938 | 1437 | 47 |
Base
| project | similarity index | total files | changed files |
|---|---|---|---|
| cpython | 0.76082 | 1789 | 1634 |
| django | 0.99922 | 2760 | 114 |
| transformers | 0.99855 | 2587 | 586 |
| twine | 0.99982 | 33 | 2 |
| typeshed | 0.99953 | 3496 | 2173 |
| warehouse | 0.99648 | 648 | 41 |
| zulip | 0.99928 | 1437 | 54 |
I expect that changing our pragma comment handling will improve the compatibility further.
crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/tuple.py
Outdated
Show resolved
Hide resolved
16f6617 to
c2e6dea
Compare
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 #6771
Summary
This PR adds logic to measure line suffixes using the new
reserved_widthfield added in:LineSuffixreserved width #6830In order to resolve the instability mentioned here, I've added logic to include parentheses if relevant expressions break (added in e2b6f04). See below for more details on our options.
I made the decision to use option number 2 listed further down only because it had less impact on the current fixtures, and the similarity reports were roughly the same.
Test Plan
Current fixtures and added the following to the tuple fixtures
And fixtures for https://play.ruff.rs/39e4c196-e81e-4b27-848e-4a535a746def which tests #6901 (comment)
TODO:
Here are the stability check/similarity results for two potential paths we can take to address the conditional logic needed in order to resolve the ecosystem checks:
Diff
Diff