DEV Community


VSCode: Setting line lengths in the Black Python code formatter

adamlombard profile image Adam Lombard (he/him) ・1 min read

The docs for the Black Python code formatter say that the formatter "is not configurable". This is largely true, but if you have Black set up to work in VSCode, you can configure the line length.

In VSCode, go 'Code -> Preferences -> Settings' and search for "python formatting black args".

Add two separate arguments, in this order: --line-length and n, where "n" is your desired number of allowed characters per line:

Interface for adding Black formatting arguments in VSCode

A few notes about line lengths in Python:


Editor guide
jordanahaines profile image
Jordan Haines

Definitely going to reference this very time I start a new project -- right after I re-learn that setting max line length in .pylintrc is not a substitute for the setting Adam's proposed here. Thanks Adam!

adamlombard profile image
Adam Lombard (he/him) Author

You're welcome, Jordan! 🙂

simkimsia profile image

Thank you this helps!

adamlombard profile image
waylonwalker profile image
Waylon Walker

119 seems uncomfortable! Then again I have never done Django and might be missing some context here.

I generally stick to black defaults and change my flake8 config to match.