Skip to content

Using Flake8 for Style Checks

What Flake8 checks

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

Run

bash
flake8 .
bash
flake8 .

Example configuration

In .flake8.flake8:

ini
[flake8]
max-line-length = 88
extend-ignore = E203,W503
exclude = .git,__pycache__,.venv,build,dist
ini
[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