Flake8 Black Plugin

0.4.0 · active · verified Mon Apr 13

flake8-black is an MIT licensed Flake8 plugin designed to integrate Black, the uncompromising code formatter, into the Flake8 ecosystem. It allows developers to validate their Python code style against Black's rules as part of their linting process, typically used in continuous integration or pre-commit hooks. The current version is 0.4.0, and it generally follows Black's release cadence for compatibility updates.

Warnings

Install

Quickstart

Install flake8-black along with flake8 and black. Create a .flake8 configuration file in your project root to align Flake8's settings with Black's, particularly the `max-line-length` to 88 and ignoring conflicting style checks like `E203` (whitespace before ':'), `W503` (line break before binary operator), and `E701` (multiple statements on one line, for empty classes). Then, simply run `flake8` as usual.

# my_module.py

def my_function(  # This line is intentionally long to trigger Black's reformatting
    argument_one: str,
    argument_two: int,
) -> None:
    print(f"Hello {argument_one}, your number is {argument_two}.")


# .flake8 (configuration file in project root)
# [flake8]
# max-line-length = 88
# extend-ignore = E203, W503, E701

# To run flake8 with flake8-black:
# flake8 my_module.py

view raw JSON →