Skip to content
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

Formatter: Implicit concatenation in compare expressions #7193

Merged
merged 1 commit into from
Sep 8, 2023

Conversation

MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Sep 6, 2023

Summary

This PR implements the logic for breaking implicit concatenated strings before compare expressions by building on top of #7145

The main change is a new BinaryLike enum that has the BinaryExpression and CompareExpression variants. Supporting both variants requires some downstream changes but doesn't introduce any new concepts.

Test Plan

I added a few more tests. The compatibility improvements are minor but we now perfectly match black on twine 🥳

PR

project similarity index total files changed files
cpython 0.76083 1789 1632
django 0.99966 2760 58
transformers 0.99928 2587 454
twine 1.00000 33 0
typeshed 0.99978 3496 2173
warehouse 0.99824 648 22
zulip 0.99948 1437 28

Base

project similarity index total files changed files
cpython 0.76083 1789 1633
django 0.99966 2760 58
transformers 0.99928 2587 454
twine 0.99982 33 1
typeshed 0.99978 3496 2173
warehouse 0.99823 648 23
zulip 0.99948 1437 28

@MichaReiser MichaReiser added the formatter Related to the formatter label Sep 6, 2023
@MichaReiser MichaReiser added this to the Formatter: Beta milestone Sep 6, 2023
}

impl<'a> BinaryLike<'a> {
fn flatten(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly moved from flatten_binary_expression except that it now supports compare expressions too

@codspeed-hq

This comment was marked as outdated.

Base automatically changed from flatten-binary-expression to main September 8, 2023 06:51
Copy link
Member

@konstin konstin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100% on twine!

@MichaReiser MichaReiser merged commit c260762 into main Sep 8, 2023
16 checks passed
@MichaReiser
Copy link
Member Author

Merge Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants