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

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

Closed
yilei opened this issue Feb 15, 2023 · 0 comments · Fixed by #3589
Closed
Labels
F: linebreak How should we split up lines? F: parentheses Too many parentheses, not enough parentheses, and so on. T: bug Something isn't working

Comments

@yilei
Copy link
Contributor

yilei commented Feb 15, 2023

Before:

with (
      mock.patch.object(
          self.xxx_xxxxxx, "xxxxxxxxxx", autospec=True
      ),
      mock.patch.object(
          self.xxx_xxxxxx, "xxxxxxxxxx", autospec=True, return_value="xxxx"
      )
  ):
    pass


with (
      mock.patch.object(
          self.xxx_xxxxxx, "xxxxxxxxxx", autospec=True
      ) as a,
      mock.patch.object(
          self.xxx_xxxxxx, "xxxxxxxxxx", autospec=True, return_value="xxxx"
      )
  ):
    pass


with (
      mock.patch.object(
          self.xxx_xxxxxx, "xxxxxxxxxx", autospec=True
      ),
      mock.patch.object(
          self.xxx_xxxxxx, "xxxxxxxxxx", autospec=True, return_value="xxxx"
      ) as b
  ):
    pass


with (
      mock.patch.object(
          self.xxx_xxxxxx, "xxxxxxxxxx", autospec=True
      ),
      mock.patch.object(
          self.xxx_xxxxxx, "xxxxxxxxxx", autospec=True, return_value="xxxx"
      ),
  ):
    pass

After:

with mock.patch.object(self.xxx_xxxxxx, "xxxxxxxxxx", autospec=True), mock.patch.object(
    self.xxx_xxxxxx, "xxxxxxxxxx", autospec=True, return_value="xxxx"
):
    pass


with mock.patch.object(
    self.xxx_xxxxxx, "xxxxxxxxxx", autospec=True
) as a, mock.patch.object(
    self.xxx_xxxxxx, "xxxxxxxxxx", autospec=True, return_value="xxxx"
):
    pass


with (
    mock.patch.object(self.xxx_xxxxxx, "xxxxxxxxxx", autospec=True),
    mock.patch.object(
        self.xxx_xxxxxx, "xxxxxxxxxx", autospec=True, return_value="xxxx"
    ) as b,
):
    pass


with (
    mock.patch.object(self.xxx_xxxxxx, "xxxxxxxxxx", autospec=True),
    mock.patch.object(
        self.xxx_xxxxxx, "xxxxxxxxxx", autospec=True, return_value="xxxx"
    ),
):
    pass

Playground link.

I'll work on a fix.

@yilei yilei added the T: style What do we want Blackened code to look like? label Feb 15, 2023
@ichard26 ichard26 added T: bug Something isn't working F: parentheses Too many parentheses, not enough parentheses, and so on. F: linebreak How should we split up lines? and removed T: style What do we want Blackened code to look like? labels Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: linebreak How should we split up lines? F: parentheses Too many parentheses, not enough parentheses, and so on. T: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants