flake8-rst-docstrings

0.4.0 · active · verified Thu Apr 16

flake8-rst-docstrings is an MIT-licensed plugin for Flake8 that validates Python docstring markup as reStructuredText (RST). It leverages the `docutils` library and `restructuredtext-lint` internally to perform checks, ensuring that docstrings conform to RST syntax. The library is actively maintained, with its current version being 0.4.0, and development tracked on GitHub.

Common errors

Warnings

Install

Quickstart

After installing, flake8-rst-docstrings automatically integrates with flake8. Simply run flake8 on your Python files. You can configure additional RST roles, directives, or ignore specific checks in your flake8 configuration file (e.g., .flake8, setup.cfg, pyproject.toml).

import os

def example_function(param1: str, param2: int):
    """This is an example docstring.

    :param param1: The first parameter.
    :type param1: str
    :param param2: The second parameter.
    :type param2: int
    :raises ValueError: If param2 is negative.
    :return: A concatenated string.
    :rtype: str

    .. warning:: This is a reStructuredText warning.
    """
    if param2 < 0:
        raise ValueError("param2 cannot be negative")
    return f"{param1}-{param2}"


# To run flake8, save the above code as 'example.py' and execute:
# flake8 example.py

view raw JSON →