Black: Unnecessary split in left hand side of assignment due to multiline string

Created on 14 Mar 2019  路  1Comment  路  Source: psf/black

Hi, I'm experience strange behavior when I use dicts and triple-quotes strings, for example:

a["b"] = f"""Some really long
    long string."""

ends up like this:

a[
   "b"
] = f"""Some really long
    long string."""

Is it expected behavior or? If yes, how can one disable it?

Operating system: Linux Ubuntu 18.04
Python version: 3.6
Black version: 18.9b0
Does also happen on master: yes

design stable

Most helpful comment

It's a bug. It stems from Black seeing that the right hand side doesn't fit in a line (it doesn't, it's a multiline string!) and tries to split the line by any other means.

In this case, it should recognize that the split made matters worse and abort. But that's not super easy to do at this point. We'll be fixing this though.

>All comments

It's a bug. It stems from Black seeing that the right hand side doesn't fit in a line (it doesn't, it's a multiline string!) and tries to split the line by any other means.

In this case, it should recognize that the split made matters worse and abort. But that's not super easy to do at this point. We'll be fixing this though.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bhearsum picture bhearsum  路  3Comments

dimaqq picture dimaqq  路  3Comments

JelleZijlstra picture JelleZijlstra  路  3Comments

madig picture madig  路  3Comments

quodlibetor picture quodlibetor  路  3Comments