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

Black --preview crashes with nested long dict str keys #3261

Closed
yilei opened this issue Sep 6, 2022 · 0 comments · Fixed by #3262
Closed

Black --preview crashes with nested long dict str keys #3261

yilei opened this issue Sep 6, 2022 · 0 comments · Fixed by #3262
Labels
C: crash Black is crashing

Comments

@yilei
Copy link
Contributor

yilei commented Sep 6, 2022

Describe the bug

black --preview crashed on some code.

To Reproduce

For example, take this code:

v = {
    ('a_very_long_str_a_very_long_str_a_very_long_str_a_very_long_str_'
     'a_very_long_str_a_very_long_str_a_very_long_str_'): {
        'key':
            'value',
    },
}

And run it with these arguments:

$ black file.py --preview

The resulting error is:

error: cannot format /Users/yileiyang/Downloads/t.py: Cannot parse: 3:122:         "a_very_long_str_a_very_long_str_a_very_long_str_a_very_long_str_a_very_long_str_a_very_long_str_a_very_long_str_": {

Oh no! 💥 💔 💥
1 file failed to reformat.

Expected behavior

Should not crash.

Environment

  • Black's version: 22.8.1.dev4+g383b228
  • OS and Python version: macOS, Python 3.9.12

Additional context

Looks like this was caused by #3162, I'll take a look.

@yilei yilei added the T: bug Something isn't working label Sep 6, 2022
@ichard26 ichard26 added C: crash Black is crashing and removed T: bug Something isn't working labels Sep 14, 2022
@ichard26 ichard26 added this to the Release 22.9.0 milestone Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: crash Black is crashing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants