API Reference

In addition to the Flake8 plugin, the following public API is available to allow other plugins to build on top of flake8-params.

Classes:

Plugin(tree)

A Flake8 plugin which checks for mismatches between function signatures and docstring params.

Visitor()

AST node visitor for identifying mismatches between function signatures and docstring params.

Functions:

check_params(signature_args, docstring_args, …)

Check if signature and docstring parameters match, and return the flake8 error code if not.

get_decorator_names(function)

Returns an iterator of the dotted names of decorators for the given function.

get_docstring_args(docstring)

Extract arguments from the docstring.

get_signature_args(function)

Extract arguments from the function signature.

get_decorator_names(function)[source]

Returns an iterator of the dotted names of decorators for the given function.

Parameters

function (Union[AsyncFunctionDef, FunctionDef, ClassDef])

Return type

Iterator[str]

get_docstring_args(docstring)[source]

Extract arguments from the docstring.

Parameters

docstring (str)

Return type

Iterator[str]

..versionadded:: 0.2.0

get_signature_args(function)[source]

Extract arguments from the function signature.

Parameters

function (Union[FunctionDef, AsyncFunctionDef])

Return type

Iterator[str]

..versionadded:: 0.2.0

check_params(signature_args, docstring_args, decorators)[source]

Check if signature and docstring parameters match, and return the flake8 error code if not.

Parameters
  • signature_args (List[str])

  • docstring_args (List[str])

  • decorators (List[str]) – List of dotted names (e.g. foo.bar, for @foo.bar()) of decorators for the function or class.

Return type

Optional[str]

Returns

Either a flake8 error code and description, or None if no errors were detected.

class Plugin(tree)[source]

Bases: Plugin[Visitor]

A Flake8 plugin which checks for mismatches between function signatures and docstring params.

Parameters

tree (AST) – The abstract syntax tree (AST) to check.

class Visitor[source]

Bases: Visitor

AST node visitor for identifying mismatches between function signatures and docstring params.