A set of flake8 plugins that check Python code against the OpenStack style guide.
peterjc/flake8-black
A flake8 plugin that runs the black code formatter's check mode, reporting formatting differences as flake8 BLK violations.
- Stars
- 167
- Forks
- 11
- Open issues
- 3
- Last commit
- 4 days ago
What is it?
flake8-black is a flake8 plugin that runs black in check mode as part of flake8 linting. Any file black would reformat is reported as a BLK100 violation, so style checks from black can be run through the same flake8 command used for other lint rules.
The plugin is useful in git pre-commit hooks and continuous integration, where a single flake8 invocation can cover both black formatting and other checks. It reads black settings such as target_version, skip_string_normalization and line_length from pyproject.toml, and accepts a --black-config option for a shared configuration file. It also reports internal errors under BLK9xx codes, such as unreadable files or invalid TOML.
The README notes that the plugin does not honour black's include and exclude settings, so files excluded from black must also be excluded in flake8. Pinning a specific black version is recommended, since black updates can introduce new BLK100 violations.
Key features
- 01Reports files black would reformat as BLK100 flake8 violations.
- 02Reads black settings such as line_length and target_version from pyproject.toml.
- 03Accepts a --black-config option to point to a shared configuration file.
- 04Reports internal problems such as unreadable files or invalid TOML under BLK9xx codes.
- 05Installable from PyPI or conda-forge.
Use cases
- Running black style checks alongside other flake8 rules in CI.
- Enforcing consistent formatting through a git pre-commit hook.
- Sharing one black configuration across several Python projects.
Quick start
- 1
Install the plugin from PyPI with pip
pip install flake8-black - 2
Run flake8 on a Python file to see BLK codes
flake8 example.py
Things to know
- It does not respect black's include and exclude settings, so those files need separate flake8 exclusion.
- Versions from 0.3.7 onward do not work with black 25.9.0 as stated in the README, though v0.4.0 is pending to fix this.
In collections
Topics
FAQ
- What is flake8-black?
- A flake8 plugin that runs the black code formatter's check mode, reporting formatting differences as flake8 BLK violations. flake8-black is a flake8 plugin that runs black in check mode as part of flake8 linting. Any file black would reformat is reported as a BLK100 violation, so style checks from black can be run through the same flake8 command used for other lint rules.
- Is flake8-black free to use? What license does it have?
- flake8-black is open source under the MIT license. Check the license terms before using it in commercial products.
- Is flake8-black still maintained?
- Actively maintained. The last commit to flake8-black was on Nov 3, 2026.
- What can I use flake8-black for?
- Running black style checks alongside other flake8 rules in CI. Enforcing consistent formatting through a git pre-commit hook. Sharing one black configuration across several Python projects.
- How do I install flake8-black?
- Install the plugin from PyPI with pip: pip install flake8-black Run flake8 on a Python file to see BLK codes: flake8 example.py
- Where can I get flake8-black?
- The source code and installation instructions are on GitHub: https://github.com/peterjc/flake8-black
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Python command-line tool that automatically reformats docstrings to follow PEP 257 conventions.
A Python linter that wraps PyFlakes, pycodestyle and McCabe into one command, with support for third-party plugins.
Command-line tool and flake8 plugin that enforces shared config settings across multiple projects, and can fix config files automatically.
A flake8 and Pylama plugin that checks whether Python imports are grouped and ordered according to a chosen style guide.
A CLI tool that runs Python linters and formatters such as ruff, isort, black, mypy and flake8 directly on Jupyter Notebooks.