eric7.Plugins.CheckerPlugins.CodeStyleChecker.Miscellaneous.DefaultMatchCaseVisitor

Module implementing a node visitor to check default match cases.

Global Attributes

None

Classes

DefaultMatchCaseVisitor Class implementing a node visitor to check default match cases.

Functions

None


DefaultMatchCaseVisitor

Class implementing a node visitor to check default match cases.

Note: This class is modeled after flake8-spm v0.0.1.

Derived from

ast.NodeVisitor

Class Attributes

None

Class Methods

None

Methods

DefaultMatchCaseVisitor Constructor
__badNodes Private method to yield bad match nodes.
__emptyMatchDefault Private method to check for an empty default match case.
__findBadNode Private method returning a reference to the bad node of a case node.
__lastStatementDoesNotRaise Private method to check that the last case statement does not raise an exception.
__returnPrecedesExceptionRaising Private method to check that no return precedes an exception raising.
visit_Match Public method to handle Match nodes.

Static Methods

None

DefaultMatchCaseVisitor (Constructor)

DefaultMatchCaseVisitor()

Constructor

DefaultMatchCaseVisitor.__badNodes

__badNodes(node)

Private method to yield bad match nodes.

node (ast.Match)
reference to the node to be processed
Yield:
tuple containing a reference to bad match case node and the corresponding issue code
Yield Type:
tyuple of (ast.AST, str)

DefaultMatchCaseVisitor.__emptyMatchDefault

__emptyMatchDefault(case)

Private method to check for an empty default match case.

case (ast.match_case)
reference to the node to be processed
Return:
flag indicating an empty default match case
Return Type:
bool

DefaultMatchCaseVisitor.__findBadNode

__findBadNode(case)

Private method returning a reference to the bad node of a case node.

case (ast.match_case)
reference to the node to be processed
Return:
reference to the bad node
Return Type:
ast.AST

DefaultMatchCaseVisitor.__lastStatementDoesNotRaise

__lastStatementDoesNotRaise(case)

Private method to check that the last case statement does not raise an exception.

case (ast.match_case)
reference to the node to be processed
Return:
flag indicating that the last case statement does not raise an exception
Return Type:
bool

DefaultMatchCaseVisitor.__returnPrecedesExceptionRaising

__returnPrecedesExceptionRaising(case)

Private method to check that no return precedes an exception raising.

case (ast.match_case)
reference to the node to be processed
Return:
flag indicating that a return precedes an exception raising
Return Type:
bool

DefaultMatchCaseVisitor.visit_Match

visit_Match(node)

Public method to handle Match nodes.

node (ast.Match)
reference to the node to be processed
Up