DEV Community

Robert Rees for We Got POP

Posted on

Getting Black and isort to agree on formatting

We have been using Black for a while to standardise our code formatting and reduce unproductive time in code reviews discussing syntax.

When we introduced it we had disabled our isort formatting due to an issue but when it came time to reintroduce it I found that black and isort were engaged in a formatting war both trying to change the formatting of a few files whenever they were run.

isort now has some advice on compatibility that wasn't available at the time (and which as a result I haven't tried).

This is the configuration file I ended up using for our code.

Automated code formatting has been a massively time saver in terms of code review and consistency across the codebase. If you're not already doing it then it is definitely one of the better new year resolutions you could make.

Discussion (0)