Black: A couple of weird things I have found.

Created on 18 May 2019  路  4Comments  路  Source: psf/black

Howdy! Sorry you're having trouble. To expedite your experience,
provide some basics for me:

Operating system:
Python version: Python 3.7.3
Black version: black, version 19.3b0
Does also happen on master: Yes

When I run $ black *

  • Mishap 1:
    My requirements.txt which contains opencv-python this is getting updated to opencv - python.
  • Mishap 2:
    A dictionary like config.settings["foo"]["bar"]["baz"] = 1 is getting converted to:
config.settings["foo"]["bar"][
    "baz"
] = 1

even within the max line.

Most helpful comment

For your first problem, you should probably run black . instead, so Black runs only on Python files, not files that aren't Python but happen to be parseable as such.

All 4 comments

For your first problem, you should probably run black . instead, so Black runs only on Python files, not files that aren't Python but happen to be parseable as such.

For your second problem, I cannot reproduce it locally with the same Python and Black 19.3b0 or with black.now.sh (also 19.3b0).

What config settings do you have?

I can reproduce "Mishap 2" using line length 30:
black.now.sh
But this is probably not a very typical setting.

@robin-bloehm-mck what do you prefer Black to do in that case?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stefanoborini picture stefanoborini  路  54Comments

adamehirsch picture adamehirsch  路  48Comments

bofm picture bofm  路  72Comments

kindjacket picture kindjacket  路  21Comments

spapanik picture spapanik  路  23Comments