def test_evalutor_must_resolve_all_call_info_without_errors(project, fname):
    scope = Scope(ast.parse(open(fname).read()), '', None, 'module')
    scope.project = project
    scope.filename = fname

    call_extractor = CallExtractor()
    for s in traverse_tree(scope):
        for line, func, args in call_extractor.process(s.node):
            if not args: continue
            func = s.eval(func, False)
Exemple #2
0
def create_scope(project, code, filename=None):
    source = cleantabs(code)
    lines = []
    pos = 0
    while True:
        pos = source.find('|', pos)
        if pos >= 0:
            lines.append(source.count('\n', 0, pos) + 1)
            pos += 1
        else:
            break

    ast, _ = fix(source.replace('|', ''))
    scope = Scope(ast, '', None, 'module')
    scope.project = project
    scope.filename = filename

    if lines:
        result = []
        for line in lines:
            result.extend([scope.get_scope_at(source, line), line])
        return result
    else:
        return scope