Previously we looked at how to -- Style your Python Code like a Pro -- using the tool, Black.
However, what about if there is a typo in your code? For example, a missing colon or closing bracket. This is where linting comes into play.

Linting is the process of running a program that will analyze code for potential errors.

A popular Python linter that I like to use is Flake8. Below shows an example:

# Install
$ pip install flake8

# Sample file
$ cat       
def print_devices(devices) # missing :
    for d in devices:

# Perform lint
$ flake8 E999 SyntaxError: invalid syntax E113 unexpected indentation

Linting isn't only limited to Python. For example, there is Ansible Lint, which validates your Ansible playbooks (see here

Want to Learn Network Automation?
Join our membership and get access to:
  • 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
  • Tech demos and sessions

Join Now ➜