mistral.hacking package

Submodules

mistral.hacking.checks module

Mistral’s pep8 extensions.

In order to make the review process faster and easier for core devs we are adding some Mistral specific pep8 checks. This will catch common errors.

There are two types of pep8 extensions. One is a function that takes either a physical or logical line. The physical or logical line is the first param in the function definition and can be followed by other parameters supported by pep8. The second type is a class that parses AST trees. For more info please see pep8.py.

class mistral.hacking.checks.BaseASTChecker(tree, filename)

Bases: ast.NodeVisitor

Provides a simple framework for writing AST-based checks.

Subclasses should implement visit_* methods like any other AST visitor implementation. When they detect an error for a particular node the method should call self.add_error(offending_node). Details about where in the code the error occurred will be pulled from the node object.

Subclasses should also provide a class variable named CHECK_DESC to be used for the human readable error message.

add_error(node, message=None)

Add an error caused by a node to the list of errors for pep8.

run()

Called automatically by pep8.

class mistral.hacking.checks.CheckForLoggingIssues(tree, filename)

Bases: mistral.hacking.checks.BaseASTChecker

visit_Assign(node)

Look for ‘LOG = logging.getLogger’

This handles the simple case:
name = [logging_module].getLogger(...)
visit_Call(node)

Look for the ‘LOG.*’ calls.

visit_Import(node)
visit_ImportFrom(node)

Module contents

Table Of Contents

Project Source

This Page