Skip to content

Using Flake8 for Style Checks

What Flake8 checks

  • style (PEP8-ish)
  • unused imports
  • simple logical issues

Run

flake8 .
flake8 .

Example configuration

In .flake8.flake8:

[flake8]
max-line-length = 88
extend-ignore = E203,W503
exclude = .git,__pycache__,.venv,build,dist
[flake8]
max-line-length = 88
extend-ignore = E203,W503
exclude = .git,__pycache__,.venv,build,dist
  • flake8-bugbearflake8-bugbear
  • flake8-comprehensionsflake8-comprehensions
  • flake8-docstringsflake8-docstrings

Tip

If you use Black, align flake8 ignores with Black defaults.

๐Ÿงช Try It Yourself

Exercise 1 โ€“ Write a unittest TestCase

Exercise 2 โ€“ assertRaises

Exercise 3 โ€“ setUp and tearDown

If this helped you, consider buying me a coffee โ˜•

Buy me a coffee

Was this page helpful?

Let us know how we did