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

Crash in preview style with assert + parenthesized string #3414

Closed
JelleZijlstra opened this issue Dec 10, 2022 · 1 comment · Fixed by #3415
Closed

Crash in preview style with assert + parenthesized string #3414

JelleZijlstra opened this issue Dec 10, 2022 · 1 comment · Fixed by #3415
Labels
C: crash Black is crashing F: trailing comma Full of magic T: bug Something isn't working

Comments

@JelleZijlstra
Copy link
Collaborator

assert xxxxxxxxx.xxxxxxxxx.xxxxxxxxx(
    xxxxxxxxx
).xxxxxxxxxxxxxxxxxx(), (
    "xxx {xxxxxxxxx} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)

Running black --preview on this file results in error: cannot format xxxxxx.py: Unable to match a closing bracket to the following opening bracket: .

This is a regression in 22.12.0. It bisects to #3370, cc @yilei.

@JelleZijlstra JelleZijlstra added T: bug Something isn't working C: crash Black is crashing F: trailing comma Full of magic labels Dec 10, 2022
@yilei
Copy link
Contributor

yilei commented Dec 10, 2022

Thanks for the cc, I'll take a look!

JelleZijlstra pushed a commit that referenced this issue Dec 10, 2022
The bug is in the `get_leaves_inside_matching_brackets` on the third line below:

```python
assert xxxxxxxxx.xxxxxxxxx.xxxxxxxxx(
    xxxxxxxxx
).xxxxxxxxxxxxxxxxxx(), (
    "xxx {xxxxxxxxx} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)
```

Including the invisible paren, third line is `).xxxxxxxxxxxxxxxxxx()), (`, that it has a matched pair then an unmatched closing paren afterwards. This PR ensures the returned leaves are actually matched.

Fixes #3414.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: crash Black is crashing F: trailing comma Full of magic T: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants