Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Flake8

Flake8 is a wrapper around these tools:

  • PyFlakes

  • pep8

  • Ned Batchelder’s McCabe script

Flake8 runs all the tools by launching the single flake8 script. It displays the warnings in a per-file, merged output.

It also adds a few features:

  • files that contain this line are skipped:

    # flake8: noqa
  • lines that contain a # noqa comment at the end will not issue warnings.

  • a Git and a Mercurial hook.

  • a McCabe complexity checker.

  • extendable through flake8.extension entry points.

QuickStart

pip install flake8

To run flake8 just invoke it against any directory or Python module:

$ flake8 coolproject
coolproject/mod.py:97:1: F401 'shutil' imported but unused
coolproject/mod.py:625:17: E225 missing whitespace around operato
coolproject/mod.py:729:1: F811 redefinition of function 'readlines' from line 723
coolproject/mod.py:1028:1: F841 local variable 'errors' is assigned to but never used

The outputs of PyFlakes and pep8 (and the optional plugins) are merged and returned.

flake8 offers an extra option: –max-complexity, which will emit a warning if the McCabe complexity of a function is higher than the value. By default it’s deactivated:

$ flake8 --max-complexity 12 coolproject
coolproject/mod.py:97:1: F401 'shutil' imported but unused
coolproject/mod.py:625:17: E225 missing whitespace around operator
coolproject/mod.py:729:1: F811 redefinition of unused 'readlines' from line 723
coolproject/mod.py:939:1: C901 'Checker.check_all' is too complex (12)
coolproject/mod.py:1028:1: F841 local variable 'errors' is assigned to but never used
coolproject/mod.py:1204:1: C901 'selftest' is too complex (14)

This feature is quite useful to detect over-complex code. According to McCabe, anything that goes beyond 10 is too complex. See https://en.wikipedia.org/wiki/Cyclomatic_complexity.

Frequently Asked Questions

Why does flake8 pin the version of pep8?

Version 1.6 of pep8 doesn’t work properly with flake8. Until pep8 releases a version that works, flake8 pins the version of pep8 so that flake8 will work as a whole.

Is flake8 broken?

Flake8 combines two other projects that are significant on their own: pep8 and PyFlakes. If flake8 is doing something you don’t like, it is quite likely that the problem lies in one of those other projects. You can run them separately to see if they are the cause of your difficulties. We greatly appreciate your efforts to diagnose the source of the problem before reporting bugs against flake8.

Questions or Feedback

If you have questions you’d like to ask the developers, or feedback you’d like to provide, feel free to use the mailing list: code-quality@python.org We would love to hear from you. Additionally, if you have a feature you’d like to suggest, the mailing list would be the best place for it.

Release files for flake8 3.0.0b1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flake8 3.0.0b1
File Size Uploaded
flake8-3.0.0b1.tar.gz 1.8 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for flake8 3.0.0b1
File Interpreter ABI Platform
flake8-3.0.0b1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 1.9 MB

Release files / flake8-3.0.0b1.tar.gz

Download URL flake8-3.0.0b1.tar.gz
Size 1.8 MB
Tags Source
SHA-256 checksum
How to use checksums
d25017510f2195c87d12d879c6498ef6091a2ca05035d3b7ad17b2f93d416453
BLAKE2b-256 checksum
How to use checksums
0ab9758590c8e4dbefd4cfd34f1decef14baa89a4734b6c8e04f4740c2f0f726
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / flake8-3.0.0b1-py2.py3-none-any.whl

Download URL flake8-3.0.0b1-py2.py3-none-any.whl
Size 80.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
52650a7a0124ee0d988fab3e1c812c36f0843ead932afbf480514785903924c1
BLAKE2b-256 checksum
How to use checksums
140f2883d32c2606d5ae2da0ec94f4168841af186c04bacb1140c7e32ad1d7ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

7.3.0

2 release files

7.2.0

2 release files

7.1.2

2 release files

7.1.1

2 release files

7.1.0

2 release files

7.0.0

2 release files

6.1.0

2 release files

6.0.0

2 release files

5.0.4

2 release files

5.0.3

2 release files

5.0.2

2 release files

5.0.1

2 release files

5.0.0

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.9.2

2 release files

3.9.1

2 release files

3.9.0

2 release files

3.8.4

2 release files

3.8.3

2 release files

3.8.2

2 release files

3.8.1

2 release files

3.8.0

2 release files

3.7.9

2 release files

3.7.8

2 release files

3.7.7

2 release files

3.7.6

2 release files

3.7.5

2 release files

3.7.4

2 release files

3.7.3

2 release files

3.7.2

2 release files

3.7.1

2 release files

3.7.0

2 release files

3.6.0

2 release files

3.5.0

2 release files

3.4.1

2 release files

3.4.0

2 release files

3.3.0

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.4

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

This release

3.0.0b1 This release

2 release files

2.6.2

2 release files

2.6.1

2 release files

2.6.0

2 release files

2.5.5

2 release files

2.5.4

2 release files

2.5.3

2 release files

2.5.2

2 release files

2.5.1

2 release files

2.5.0

2 release files

2.4.1

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.5

1 release file

2.2.4

1 release file

2.2.3

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

1 release file

2.0

1 release file

1.7.0

1 release file

1.6.2

1 release file

1.6.1

1 release file

1.6

1 release file

1.5

1 release file

1.4

1 release file

1.3.1

1 release file

1.3

1 release file

1.2

1 release file

1.1

1 release file

1.0

1 release file

0.9

1 release file

0.8

1 release file

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page