module documentation

Undocumented

Function filter_stmts Filter the given list of statements to remove ignorable statements. If base_node is not a frame itself and the name is found in the inner frame locals, statements will be filtered to remove ignorable statements according to base_node's location.
Function get_assign_type Get the node that assigned the name represented by the node.
Function has_base Check if this ast.ClassDef node inherits from the given type.
Function optionally_assigns Whether this node optionally assigns a variable.
Constant ASSIGNMENT_NODES Undocumented
Constant CONTAINER_NODES Undocumented
Constant FILTER_STATEMENTS_NODES Undocumented
Constant OPTIONAL_ASSIGN_NODES Undocumented
Constant PARENT_ASSIGNMENT_NODES Undocumented
Function _assign_type_get_filtered_stmts method used in filter_stmts
Function _comprehension_get_filtered_stmts method used in filter_stmts
Function _filter_statement_get_filtered_stmts method used in _filter_stmts to get statements and trigger break
Function _get_filtered_node_statements Returns the list of tuples (node, node.statement) for all stmt_nodes.
Function _get_filtered_stmts No summary
def filter_stmts(base_node, stmts, frame, offset): (source)

Filter the given list of statements to remove ignorable statements. If base_node is not a frame itself and the name is found in the inner frame locals, statements will be filtered to remove ignorable statements according to base_node's location.

Parameters
base_node:ASTNodeUndocumented
stmts:list(ASTNode)The statements to filter. This list generally comes from the ASTNode.locals atribute that maps strings to ast.Name or ast.Attribute
frame:ASTNodeThe frame that all of the given statements belong to.
offset:intThe line offset to filter statements up to.
Returns
list(ASTNode)The filtered statements.
def get_assign_type(node): (source)

Get the node that assigned the name represented by the node.

For a ast.Name, return the parent ast.Assign or ast.AnnAssign node that define the name.

For others, it return the statement it self.

Parameters
node:LocalsAssignTUndocumented
Returns
ASTNodeUndocumented
def has_base(self, node): (source)

Check if this ast.ClassDef node inherits from the given type.

Parameters
node:ASTNodeThe node defining the base to look for. Usually this is a Name node.
Returns
boolUndocumented
def optionally_assigns(self): (source)

Whether this node optionally assigns a variable.

This is for loop assignments because loop won't necessarily perform an assignment if the loop has no iterations.

Returns
boolUndocumented
CONTAINER_NODES = (source)

Undocumented

Value
(ast.List, ast.Set, ast.Tuple)
OPTIONAL_ASSIGN_NODES = (source)
PARENT_ASSIGNMENT_NODES = (source)
def _assign_type_get_filtered_stmts(self, lookup_node, node, _stmts, mystmt): (source)

method used in filter_stmts

Parameters
lookup_node:ASTNodeUndocumented
node:LocalsAssignTUndocumented
_stmts:List[ASTNode]Undocumented
mystmt:Optional[ASTNode]Undocumented
Returns
Tuple[List[ASTNode], bool]Undocumented
def _comprehension_get_filtered_stmts(self, lookup_node, node, stmts, mystmt): (source)

method used in filter_stmts

Parameters
lookup_node:ASTNodeUndocumented
node:LocalsAssignTUndocumented
stmts:List[ASTNode]Undocumented
mystmt:Optional[ASTNode]Undocumented
Returns
Tuple[List[ASTNode], bool]Undocumented
def _filter_statement_get_filtered_stmts(self, _, node, _stmts, mystmt): (source)

method used in _filter_stmts to get statements and trigger break

Parameters
_:ASTNodeUndocumented
node:LocalsAssignTUndocumented
_stmts:List[ASTNode]Undocumented
mystmt:Optional[ASTNode]Undocumented
Returns
Tuple[List[ASTNode], bool]Undocumented
def _get_filtered_node_statements(base_node, stmt_nodes): (source)

Returns the list of tuples (node, node.statement) for all stmt_nodes.

Special handling for ExceptHandlers, see code comments.

Parameters
base_node:ASTNodeUndocumented
stmt_nodes:List[LocalsAssignT]Undocumented
Returns
List[Tuple[LocalsAssignT, Union[ASTstmt, ASTModuleT]]]Undocumented
def _get_filtered_stmts(self, base_node, node, _stmts, mystmt): (source)
Parameters
self:ASTNodethe assign_type.
base_node:ASTNodethe lookup context node in which the filtering happends.
node:LocalsAssignTthe LocalsAssignT node where the node to filter was assigned.
_stmts:List[ASTNode]the already filtered statements (empty list on the first iteration)
mystmt:Optional[ASTNode]the statement of the base node.
Returns
Tuple[List[ASTNode], bool]Undocumented