Pydocstyle
Pydocstyle is a static analysis tool designed to check Python code for compliance with docstring conventions, primarily PEP 257. It supports various docstring formats, including Google and NumPy styles. The project is currently at version 6.3.0, but it is officially deprecated and no longer actively maintained, with the recommendation to migrate to Ruff for docstring linting.
Warnings
- breaking The Pydocstyle project is officially deprecated and no longer actively maintained. Users are strongly recommended to migrate to Ruff, which offers full parity with pydocstyle and active development.
- deprecated Configuration files named `.pep257` and section headers `[pep257]` are deprecated for backwards compatibility. Support for these will be removed in a future major version, which is unlikely to happen given the project's deprecation.
- gotcha When using Google or NumPy docstring conventions, pydocstyle might incorrectly default to checking for one style over the other if section names (e.g., 'Returns', 'Yields') overlap. This can lead to false positives or missed errors.
- gotcha Support for TOML configuration files (e.g., `pyproject.toml`) is only enabled if the `toml` Python package is installed. If it's missing, pydocstyle will not recognize your TOML configuration.
Install
-
pip install pydocstyle
Imports
- run_check
import pydocstyle # errors = pydocstyle.run_check(paths=['your_file.py'])
Quickstart
import os
def my_function():
"""This is a sample function.
It returns a string.
"""
return "Hello"
# Save this to a file, e.g., `example.py`
# Then run from the command line:
# pydocstyle example.py
# You can also customize checks:
# pydocstyle --ignore=D100,D104 example.py