-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Use reserved width to include line suffix measurement #6901
Conversation
CodSpeed Performance ReportMerging #6901 will not alter performanceComparing Summary
|
45d5cc2
to
4e3783f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
b83d72b
to
15ebfaf
Compare
15ebfaf
to
3c210c4
Compare
cc74835
to
0aa3a86
Compare
304b606
to
caf0aae
Compare
caf0aae
to
ba678b1
Compare
crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/tuple.py
Outdated
Show resolved
Hide resolved
b050c9d
to
1745d3d
Compare
c8f4514
to
16f6617
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Closes #6771
Summary
This PR adds logic to measure line suffixes using the new
reserved_width
field added in:LineSuffix
reserved 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