Automate linting & formatting in PyCharm with your favourite tools

Run black, flake8 & other tools automatically with every file change

Johannes Schmidt
6 min readApr 1, 2022
Photo by Brett Jordan on Unsplash

If you’ve ever worked in a team, you know that to achieve code and style consistency, you need to agree on a formatter and linter. It will help you with onboarding new members to the codebase, create fewer merge conflicts and generally save time because developers don’t have to care about formatting and style while coding.

Before we dive into how to make your PyCharm run your favourite tools with every file change automatically, let’s cover a few basics.

Formatters

Formatters are tools that reformat some basic things in your code like quotes, commas, and line length. They make sure your codebase stays in a consistent style without any manual work on your end.

Popular Formatters: black, autopep8, yapf

Linters

These tools perform static analysis of source code, checking for semantic discrepancies. So “Linting” means running a tool against your code that identifies violations of style guides. The tool will check your code syntax and provide message that tell you what’s wrong with it.

--

--

Johannes Schmidt
Johannes Schmidt

Written by Johannes Schmidt

Software & Data Engineer at Datamesh GmbH. Sharing knowledge and code around software (cloud) development, data engineering & data science!