(block, var_types=None)
Filter given block returning statements with variables assignments of specific type
Filter given block returning statements with variables assignments of specific type
Filter given block returning statements with variables assignments of specific type
def find_declarations(block, var_types=None):
    """
    Filter given block returning statements with variables assignments of specific type
    """

    all_var_types = (Const, Global, Var, FreeVar)
    if var_types is None:
        var_types = all_var_types

    if isinstance(var_types, tuple):
        assert all(typ in all_var_types for typ in var_types)
    else:
        assert var_types in all_var_types

    for assign in filter_block_statements(block, (Assign)):
        rhs = assign.value
        if isinstance(rhs, var_types):
            yield assign
def find_declarations ( block , var_types = None ) : all_var_types = ( Const , Global , Var , FreeVar ) if var_types is None : var_types = all_var_types if isinstance ( var_types , tuple ) : assert all ( typ in all_var_types for typ in var_types ) else : assert var_types in all_var_types for assign in filter_block_statements ( block , ( Assign ) ) : rhs = assign . value if isinstance ( rhs , var_types ) : yield assign