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

Consistently wrap two context managers in parens (in --preview). #3589

Merged
merged 7 commits into from
Mar 10, 2023

Conversation

yilei
Copy link
Contributor

@yilei yilei commented Mar 1, 2023

Description

Fixes #3572

Checklist - did you ...

  • Add an entry in CHANGES.md if necessary?
  • Add / update tests if necessary?
  • Add new / update outdated documentation?

@yilei
Copy link
Contributor Author

yilei commented Mar 1, 2023

Attaching a diff-shades result: 3589.diff.zip

This is from running:

diff-shades analyze base.json --work-dir projects-cache --force-preview-style -- --target-version=py39
diff-shades analyze new.json --work-dir projects-cache --force-preview-style -- --target-version=py39
diff-shades compare base.json new.json --diff

@yilei
Copy link
Contributor Author

yilei commented Mar 1, 2023

Ah, the diff-shades check on CI is broken?

@ichard26
Copy link
Collaborator

ichard26 commented Mar 1, 2023

Yup. 🙃

Copy link
Collaborator

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Two nits, and a question about async with.

src/black/lines.py Outdated Show resolved Hide resolved
CHANGES.md Outdated Show resolved Hide resolved
"""Return True if the given leaf starts a with statement."""
return bool(
leaf.type == token.NAME
and leaf.value == "with"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this also cover async with? We should treat both of these the same.

Copy link
Contributor Author

@yilei yilei Mar 1, 2023

Choose a reason for hiding this comment

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

Good catch! Turns out async with isn't handled at all in #3489. It has a different code path here so the code I'm touching in this PR isn't called at all.

I filed #3591, will address separately.

yilei and others added 2 commits February 28, 2023 21:12
Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Jelle Zijlstra <[email protected]>
@yilei
Copy link
Contributor Author

yilei commented Mar 2, 2023

@ichard26 FYI I just sent ichard26/diff-shades#11 to fix diff-shades

@JelleZijlstra
Copy link
Collaborator

Thanks @yilei! I merged the diff-shades change, let's see if that's enough.

@ichard26
Copy link
Collaborator

ichard26 commented Mar 3, 2023

The workflow pulls from the stable branch which was admittedly bad design on my part (I'll rename the default branch on ichard26/diff-shades to avoid disrupting this repo). I updated it and triggered a rerun although it seems to be stuck? Let's try this again.

@ichard26 ichard26 closed this Mar 3, 2023
@ichard26 ichard26 reopened this Mar 3, 2023
@github-actions
Copy link

github-actions bot commented Mar 3, 2023

diff-shades reports zero changes comparing this PR (e8f81c9) to main (4a063a9).


What is this? | Workflow run | diff-shades documentation

@yilei
Copy link
Contributor Author

yilei commented Mar 3, 2023

Success!

@yilei
Copy link
Contributor Author

yilei commented Mar 9, 2023

Kindly ping @JelleZijlstra?

@yilei
Copy link
Contributor Author

yilei commented Mar 9, 2023

Ah sorry, I'll resolve the merge conflicts.

@JelleZijlstra JelleZijlstra self-requested a review March 9, 2023 17:25
@JelleZijlstra JelleZijlstra merged commit d16a1db into psf:main Mar 10, 2023
@yilei yilei deleted the cm branch March 10, 2023 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parens of parenthesized context managers are removed in some cases, even when targeting 3.9+
3 participants