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

Become a Network Automation Jedi
Join our membership and enjoy:
  • Deep Dive Library
  • Community Support
  • Hands-on Examples
  • Multivendor Labs (beta)

100% Satisfaction Guaranteed!
Cancel your membership at any time.

Join our Community