Flake8 vs Pylint: Comparing Python Linters

flake8 vs pylint

Stuck on flake8 vs pylint? You want to catch bugs without drowning in warnings. Flake8 is lighter and faster for common bugs and style; Pylint is stricter and deeper, and you can safely run both.

Looking at the wider field? Our roundup of best developer tools puts this comparison in context.

Item Value
Checkers bundled in Flake8 PyFlakes, pycodestyle and mccabe (three checkers)
Flake8 configuration files setup.cfg, tox.ini or .flake8; no native pyproject.toml support
Benchmark codebase size 120,000 lines of Python
Flake8 6.0.0 with bugbear, one lint 1.7 wallclock seconds, 13.1 CPU seconds
Pylint 2.17.3, one lint 14.0 wallclock seconds, 14.0 CPU seconds

Figures come from the Python Speed benchmark and the pydevtools Flake8 reference. Versions and timings change, so check the sources before you rely on them.

What each linter is built to do

Flake8 is an aggregator. It wraps three checkers into one command: PyFlakes for logical errors, pycodestyle for PEP 8 style, and mccabe for cyclomatic complexity, according to the pydevtools Flake8 reference.

Pylint has a wider brief. It describes itself as a tool that looks for programming errors, helps enforce a coding standard, sniffs for code smells, and offers simple refactoring suggestions, as quoted in the PyCon code style workshop.

Flake8 grows through plugins. The same workshop lists a few popular ones:

  • flake8-bugbear: an additional set of checks, some of them opinionated.
  • flake8-comprehensions: helps you write better list, set and dictionary comprehensions.
  • flake8-docstrings: enforces PEP 257 docstring rules.

The workshop also notes that the mccabe complexity check is disabled by default in Flake8, so you opt in if you want it.

How do their results differ on the same file?

The Jumping Rivers linting guide ran both tools on one small script. Flake8 flagged lots of whitespace and blank-line issues, while Pylint flagged naming conventions and layout such as docstrings and import order. Both pointed out unused imports.

Typical messages from that run look like this:

  • Flake8: F401 for an import that is unused, and E225 for missing whitespace around an operator.
  • Pylint: missing docstring and naming-style complaints, plus E0401, an import error reported before the code even ran.

Pylint’s message IDs start with a letter for the category, for example C for a convention check and E for an error, as the same guide explains.

A bug only deeper checks catch

The Python Speed article shows a classic trap: functions created in a loop that all end up using the last loop value. By default Flake8 won’t catch this. Adding the flake8-bugbear plugin reports B023, and Pylint reports W0640 (cell-var-from-loop).

The lesson is that a bare Flake8 install is a starting point. You often need a plugin, or Pylint, to cover trickier bug patterns.

How strict is each tool?

The PyCon workshop says Pylint is much more strict than Flake8. It adds that it is much easier to write code that makes Flake8 happy than code that satisfies Pylint, especially with unusual constructs.

If you use a framework such as Django, the same source advises installing extra plugins for it so Pylint understands the framework’s patterns.

Speed: how big is the gap?

The clearest numbers come from a benchmark by Itamar Turner-Trauring, last updated in May 2023 on the Python Speed site. It timed a real project with 120,000 lines of Python, with each tool running a single closure-capture lint. Flake8 6.0.0 with bugbear took 1.7 wallclock seconds and Pylint 2.17.3 took 14.0.

Flake8 used 13.1 CPU seconds, more than its wallclock time, because it spreads work across multiple cores. Pylint’s CPU time matched its 14.0 wallclock seconds, according to the same benchmark.

That advantage shrinks in CI. The author points out that the cloud VM used in CI often only has 2 vCPU, so Flake8 gets far less parallelism there than on a desktop.

Treat these numbers as a direction, not a guarantee. The test enabled just a single lint per tool, so it is not a race between full rule sets, and the tool versions have moved on since.

The Invent with Python comparison offers a reason for the gap: Pyflakes, the engine inside Flake8, only examines the syntax tree of each file individually. That makes it faster than Pylint, though more limited in what it can check.

flake8 vs pylint Laptop workspace
A person rests their hands on a laptop keyboard at a yellow table.

Configuration and silencing warnings

Flake8 reads its settings from setup.cfg, tox.ini or a dedicated .flake8 file. It does not natively read pyproject.toml, per the pydevtools Flake8 reference. You can silence a rule on a single line with a comment such as # noqa: E501.

If you want Flake8 settings in pyproject.toml, pydevtools notes that the third-party flake8-pyproject plugin adds that. Out of the box, Flake8 also checks lines against a limit of 79 characters, which many teams raise.

Pylint uses its own inline comment. To overrule a message on one line, add # pylint: disable=some-message with the message name, as the Jumping Rivers guide shows. Flake8’s equivalent in that guide is # noqa: F401 for an unused import.

Pylint can be noisy on a first run. One reviewer in the Invent with Python comparison says running pylint –errors-only cuts out the style suggestions and gives output similar to Pyflakes.

Which should you pick, and can you use both?

The right choice depends on what you want from a linter. A rough guide:

  • Pick Flake8 if you want quick feedback in your editor and a modest rule set that you extend with plugins.
  • Pick Pylint if you want stricter review, including code smells and refactoring hints, and you can tolerate more warnings.
  • Use both if you want the overlap and the extras. The PyCon workshop says you can safely use both at the same time.

Neither tool is a formatter. The pydevtools page says Flake8 reports problems but does not rewrite code, so many teams pair a linter with a formatter. Our explainer on what is a code formatter covers that split, and the same divide appears in JavaScript in our eslint vs prettier comparison.

What about Ruff?

As of the pydevtools Flake8 reference page, last updated on September 7, 2026, Ruff reimplements Flake8’s entire rule set with autofix support and 10-100x faster runs, and the page suggests considering Ruff for new projects. You can read the full reference for its pros and cons.

Pylint coverage is a different story. As of the Python Speed article’s May 2023 update, Ruff’s Pylint compatibility was still at an earlier stage, with many lints missing, so check the article and Ruff’s own rule list before dropping Pylint.

Frequently asked questions

Can I run Flake8 and Pylint together?

Show answer

Yes. The PyCon workshop says there is some overlap, but you can safely use both at the same time. Expect duplicate reports for things like unused imports.

Is Pylint stricter than Flake8?

Show answer

Yes. The same workshop calls Pylint much more strict, and notes it is easier to write code that makes Flake8 happy.

Does Flake8 support pyproject.toml?

Show answer

Not natively. The pydevtools comparison says the third-party flake8-pyproject plugin adds that support.

Does Flake8 catch the loop-variable closure bug by default?

Show answer

No. The Python Speed article shows that you need the bugbear plugin, which reports B023, or Pylint, which reports W0640.