Flake8 is a popular lint wrapper for python. Under the hood, it runs three other tools and combines their results:

Run Locally

The mozlint integration of flake8 can be run using mach:

$ mach lint --linter flake8 <file paths>

Alternatively, omit the --linter flake8 and run all configured linters, which will include flake8.


Only directories explicitly whitelisted will have flake8 run against them. To enable flake8 linting in a source directory, it must be added to the include directive in `tools/lint/flake8.lint. If you wish to exclude a subdirectory of an included one, you can add it to the exclude directive.

The default configuration file lives in topsrcdir/.flake8. The default configuration can be overridden for a given subdirectory by creating a new .flake8 file in the subdirectory. Be warned that .flake8 files cannot inherit from one another, so all configuration you wish to keep must be re-defined.


Only .flake8 files that live in a directory that is explicitly included in the include directive will be considered. See bug 1277851 for more details.

For an overview of the supported configuration, see flake8’s documentation.


The flake8 linter provides a --fix option. It is based on autopep8. Please note that autopep8 does NOT fix all issues reported by flake8.