flake8_helper

A helper library for Flake8 plugins.

Data:

_V

Invariant TypeVar bound to flake8_helper.Visitor.

_P

Invariant TypeVar bound to flake8_helper.Plugin.

Classes:

Visitor()

AST node visitor.

Plugin(tree)

Abstract base class for Flake8 plugins.

_V = TypeVar(_V, bound=Visitor)

Type:    TypeVar

Invariant TypeVar bound to flake8_helper.Visitor.

class Visitor[source]

Bases: NodeVisitor

AST node visitor.

Attributes:

errors

The list of Flake8 errors identified by the visitor.

Methods:

report_error(node, error)

Report an error for the given node.

errors

Type:    List[Tuple[int, int, str]]

The list of Flake8 errors identified by the visitor.

report_error(node, error)[source]

Report an error for the given node.

Parameters
_P = TypeVar(_P, bound=Plugin)

Type:    TypeVar

Invariant TypeVar bound to flake8_helper.Plugin.

class Plugin(tree)[source]

Bases: ABC, Generic

Abstract base class for Flake8 plugins.

Parameters

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

Minimum example:

Attributes:

name

The plugin name.

version

The plugin version.

visitor_class

The visitor class to use to traverse the AST.

Methods:

run()

Traverse the Abstract Syntax Tree and identify errors.

abstract property name

The plugin name.

Return type

str

abstract property version

The plugin version.

Return type

str

abstract property visitor_class

The visitor class to use to traverse the AST.

Return type

Type[~_V]

run()[source]

Traverse the Abstract Syntax Tree and identify errors.

Yields a tuple of (line number, column offset, error message, type(self))

Return type

Iterator[Tuple[int, int, str, Type[~_P]]]