-
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 BestFits for non-fluent attribute chains #6817
Merged
Merged
Conversation
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 was referenced Aug 23, 2023
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
This was referenced Aug 23, 2023
PR Check ResultsBenchmarkLinux
Windows
|
MichaReiser
force-pushed
the
maybe-parenthesize-constants-and-names
branch
from
August 23, 2023 13:33
aa7e59b
to
9ab2cb5
Compare
MichaReiser
force-pushed
the
best-fits-call-expr
branch
from
August 23, 2023 13:33
a658f3b
to
ffc115e
Compare
MichaReiser
changed the title
Use BestFits for non-call chain call expressions
Use BestFits for non-fluent call expressions
Aug 23, 2023
MichaReiser
force-pushed
the
maybe-parenthesize-constants-and-names
branch
3 times, most recently
from
August 23, 2023 16:21
701c645
to
d50042b
Compare
MichaReiser
changed the title
Use BestFits for non-fluent call expressions
Use BestFits for non-fluent attribute chains
Aug 23, 2023
MichaReiser
force-pushed
the
best-fits-call-expr
branch
from
August 23, 2023 16:39
767304d
to
cb56080
Compare
MichaReiser
commented
Aug 23, 2023
@@ -107,7 +106,8 @@ pub(super) fn is_multiline_string(constant: &ExprConstant, source: &str) -> bool | |||
let quotes = | |||
StringQuotes::parse(&contents[TextRange::new(prefix.text_len(), contents.text_len())]); | |||
|
|||
quotes.is_some_and(StringQuotes::is_triple) && contents.contains(['\n', '\r']) | |||
quotes.is_some_and(StringQuotes::is_triple) | |||
&& memchr::memchr2(b'\n', b'\r', contents.as_bytes()).is_some() |
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.
This helped offsetting the performance regression a bit
MichaReiser
force-pushed
the
maybe-parenthesize-constants-and-names
branch
from
August 23, 2023 16:54
d50042b
to
c8cb472
Compare
MichaReiser
force-pushed
the
best-fits-call-expr
branch
from
August 23, 2023 16:55
cb56080
to
c2861ef
Compare
MichaReiser
force-pushed
the
maybe-parenthesize-constants-and-names
branch
3 times, most recently
from
August 23, 2023 17:27
56f175a
to
697d820
Compare
MichaReiser
force-pushed
the
best-fits-call-expr
branch
2 times, most recently
from
August 23, 2023 21:15
e251a2e
to
7609f59
Compare
MichaReiser
commented
Aug 23, 2023
Comment on lines
100
to
116
// For asserts statements where the constant is the message and the test starts with a parenthesized node | ||
// | ||
// ```python | ||
// assert [ | ||
// a, | ||
// b, | ||
// c, | ||
// ] == expected, ( | ||
// "Message" | ||
// ) | ||
// ``` | ||
// split in the following order: | ||
// | ||
// 1. By the opening parentheses of the test | ||
// 2. Add parentheses around the message | ||
// 3. Add parentheses around the test | ||
// |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
MichaReiser
force-pushed
the
maybe-parenthesize-constants-and-names
branch
from
August 24, 2023 09:38
697d820
to
33a6c16
Compare
MichaReiser
force-pushed
the
best-fits-call-expr
branch
from
August 24, 2023 09:43
7609f59
to
a15564f
Compare
Base automatically changed from
maybe-parenthesize-constants-and-names
to
main
August 24, 2023 09:47
MichaReiser
force-pushed
the
best-fits-call-expr
branch
from
August 24, 2023 09:51
a15564f
to
92ce7de
Compare
Merged
konstin
approved these changes
Aug 24, 2023
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 is the last part of #6271. It implements the overlong parenthesizing for attribute chains (and call expressions).
The code changes are minimal. The main reason for this being its own PR is to assess the performance implication (and compatibility win)
Closes #6271
Test Plan
Base
This PR