In this lesson, you will learn:

  • what flake8 is
  • why use flake8 over pylint
  • how to install flake8
  • how to use flake8 to catch Python syntax issues
  • flake8's main configuration options
  • how to install flake8 plugins to check for additional code issues.
You can find the scripts and code for this course within the Automating Python Code Quality repo.

What is Flake8?

Flake8 is a Python linting tool that checks your Python codebase for errors, styling issues and complexity. The Flake8 library is built upon 3 tools:

  • PyFlakes - checks your Python codebase for errors
  • McCabe - checks your Python codebase for complexity
  • pycodestyle - checks your Python codebase for styling issues against PEP8.

The thing that makes Flake8 so great is that it has a great range of plugins to enhance and extend what issues and problems it can look for.

Flake8 vs Pylint

Pylint is another Python linting library. Though it is great, from my experience it’s extremely verbose in the issues and things it deems problematic. Therefore, out of the box Pylint takes time to tune and configure based on your codebase and environment. Not only this but Flake8’s ecosystem of plugins extends it to catch issues that Pylint does not support. Therefore, this course will only cover Flake8.

How to Install Flake8

To install Flake8, run the following:

poetry add -D flake8
Ready to Master Network Automation? Start Your Journey Today!
Our membership provides:
  • Full deep-dive course library (inc. Batfish, pyATS, Netmiko)
  • Code repositories inc. full course code, scripts and examples
  • 24x7 multi-vendor labs (Arista, Cisco, Juniper)
  • Private online community
  • Live monthly tech sessions
  • Access to tech session library

Join Now ➜
Close You've successfully subscribed to Packet Coders.
Close Success! Your account is fully activated, you now have access to all content.
Close Welcome back! You've successfully signed in.
Close Nearly there! To activate your account, please click the link in the email we just sent you.