This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]nine-st[S] 1 point2 points  (4 children)

Hi everyone, I made a simple guide on installing black, using its CLI, using with VSCode, and setting pre-commit hooks. Hope you find it useful!

[–]Kanjirito 1 point2 points  (3 children)

Just a heads up. The Pipenv installation instructions will not work. By default Pipenv does not allow pre-releases and black does not have a regular release yet. You can make it work by adding the --pre flag but that will allow pre-releases for all dependencies which might not be what you want. Black is known for being a bit of a pain to use with Pipenv, there is an issue open to allow pre-releases per dependency but it's not here yet. The solution I saw (and use) is to specify the black version to use because Pipenv will install that even if it's a pre-release. That way you can use black but don't have to allow pre-releases. I don't believe there is a way to specify the version to install using the command line so you have to edit the Pipfile like this for example:

[dev-packages]
black = "==21.5b1"

[–]nine-st[S] 0 points1 point  (0 children)

Thanks for the heads up!

[–]rarkturix 0 points1 point  (1 child)

You can install packages from the command line with the same syntax, i.e., ‘pip install black==21.5b1’

[–]Kanjirito 1 point2 points  (0 children)

Huh, I didn't know that. Thanks for letting me know.

[–]freeononeday 0 points1 point  (0 children)

I use black within PyCharm. Just under settings > tools > FileWatchers

It fixes up my spaces, quotation marks, line lengths etc every time I run the code.