Python ast.expr_context() Examples

The following are 3 code examples of ast.expr_context(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module ast , or try the search function .
Example #1
Source File: pyupgrade.py    From pyupgrade with MIT License 5 votes vote down vote up
def targets_same(target: ast.AST, yield_value: ast.AST) -> bool:
    for t1, t2 in zip(ast.walk(target), ast.walk(yield_value)):
        # ignore `ast.Load` / `ast.Store`
        if _all_isinstance((t1, t2), ast.expr_context):
            continue
        elif type(t1) != type(t2):
            return False
        elif not fields_same(t1, t2):
            return False
    else:
        return True 
Example #2
Source File: astpretty.py    From astpretty with MIT License 5 votes vote down vote up
def _is_sub_node(node: Any) -> bool:
    return isinstance(node, AST) and not isinstance(node, expr_context) 
Example #3
Source File: util.py    From kappa with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def __init__(self) -> None:
        # The keys are subtypes of `ast.expr_context` -- `Load`, `Store`, etc.
        self.vars_by_usage: VarsByUsageType = defaultdict(set)
        super(_FindVariablesByUsageVisitor, self).__init__()