In this lesson, you will learn,

  • what pydocstyle is
  • how to install pydocstyle
  • how to validate your docstrings using pydocstyle
  • pydocstyle's main configuration options.
You can find the scripts and code for this course within the Automating Python Code Quality repo.

What is pydocstyle?

pydocstyle is a linting tool that validates that your Python docstrings are compliant with PEP257 - for example, that the right type of quotes are used or if no docstrings have even been added at all.

How to Install pydocstyle

To install pydocstyle we just run:

$ poetry add -D pydocstyle


pydocstyle can be run against a file or directory. If a directory is specified, pydocstyle will recursively check all of the files. Examples of each are shown below:

$ pydocstyle .
$ pydocstyle dir
$ pydocstyle

Therefore, let’s say we have the following file:

❯ cat  002_linting/
def get_vlan():
    return {
        100: "VLAN100"

def get_asn():
    '''Return ASN'''
    return {
        65400: "ACME lTD"
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.