forked from VimPlug/jedi
simple function tests pass now
This commit is contained in:
@@ -372,8 +372,8 @@ def find_name(scope, name_str, position=None, search_global=False,
|
||||
if not result and isinstance(nscope, er.Instance):
|
||||
# __getattr__ / __getattribute__
|
||||
result += check_getattr(nscope, name_str)
|
||||
debug.dbg('sfn filter "%s" in (%s-%s): %s@%s' % (name_str, nscope,
|
||||
scope, result, position))
|
||||
debug.dbg('sfn filter "%s" in (%s-%s): %s@%s' % (name_str, scope,
|
||||
nscope, result, position))
|
||||
return result
|
||||
|
||||
def descriptor_check(result):
|
||||
@@ -632,7 +632,7 @@ def follow_call_list(call_list, follow_array=False):
|
||||
def follow_call(call):
|
||||
"""Follow a call is following a function, variable, string, etc."""
|
||||
path = call.generate_call_path()
|
||||
scope = call.get_parent_until(pr.Scope)
|
||||
scope = call.get_parent_until((pr.Scope, er.Execution))
|
||||
return follow_call_path(path, scope, call.start_pos)
|
||||
|
||||
|
||||
|
||||
@@ -501,14 +501,16 @@ class Execution(Executable):
|
||||
else:
|
||||
parent = self.base
|
||||
start_pos = None
|
||||
calls = pr.Array(start_pos, pr.Array.NOARRAY, parent)
|
||||
calls.values = values
|
||||
calls.keys = keys
|
||||
calls.type = array_type
|
||||
# create an Array (-> container for the statement)
|
||||
arr = pr.Array(self.module, start_pos, pr.Array.NOARRAY, parent)
|
||||
arr.values = values
|
||||
arr.keys = keys
|
||||
arr.type = array_type
|
||||
|
||||
new_param = copy.copy(param)
|
||||
if parent is not None:
|
||||
new_param.parent = parent
|
||||
new_param._commands = calls
|
||||
new_param._commands = [arr]
|
||||
new_param.is_generated = True
|
||||
name = copy.copy(param.get_name())
|
||||
name.parent = new_param
|
||||
@@ -610,7 +612,7 @@ class Execution(Executable):
|
||||
if not isinstance(stmt, pr.Statement):
|
||||
yield None, stmt
|
||||
# *args
|
||||
elif stmt.token_list[0] == '*':
|
||||
elif stmt.get_commands()[0] == '*':
|
||||
arrays = evaluate.follow_call_list([stmt.token_list[1:]])
|
||||
# *args must be some sort of an array, otherwise -> ignore
|
||||
for array in arrays:
|
||||
@@ -618,7 +620,7 @@ class Execution(Executable):
|
||||
for field in array.get_contents():
|
||||
yield None, field
|
||||
# **kwargs
|
||||
elif stmt[0] == '**':
|
||||
elif stmt.get_commands()[0] == '**':
|
||||
arrays = evaluate.follow_call_list([stmt.token_list[1:]])
|
||||
for array in arrays:
|
||||
if hasattr(array, 'get_contents'):
|
||||
@@ -632,8 +634,8 @@ class Execution(Executable):
|
||||
yield name, field
|
||||
# Normal arguments (including key arguments).
|
||||
else:
|
||||
if stmt.assignment_detail:
|
||||
key_arr, op = stmt.assignment_detail[0]
|
||||
if stmt.assignment_details:
|
||||
key_arr, op = stmt.assignment_details[0]
|
||||
# named parameter
|
||||
if key_arr and isinstance(key_arr[0], pr.Call):
|
||||
yield op[0].name, stmt
|
||||
@@ -677,7 +679,7 @@ class Execution(Executable):
|
||||
raise common.MultiLevelAttributeError(sys.exc_info())
|
||||
|
||||
def __getattr__(self, name):
|
||||
if name not in ['start_pos', 'end_pos', 'imports']:
|
||||
if name not in ['start_pos', 'end_pos', 'imports', 'module']:
|
||||
raise AttributeError('Tried to access %s: %s. Why?' % (name, self))
|
||||
return getattr(self.base, name)
|
||||
|
||||
@@ -701,7 +703,6 @@ class Execution(Executable):
|
||||
@property
|
||||
@cache.memoize_default()
|
||||
def returns(self):
|
||||
print self.copy_properties('returns')[0].parent
|
||||
return self.copy_properties('returns')
|
||||
|
||||
@property
|
||||
|
||||
@@ -31,8 +31,7 @@ def fast_parent_copy(obj):
|
||||
|
||||
for key, value in items:
|
||||
# replace parent (first try _parent and then parent)
|
||||
if key in ['parent', '_parent', '_parent_stmt'] \
|
||||
and value is not None:
|
||||
if key in ['parent', '_parent'] and value is not None:
|
||||
if key == 'parent' and '_parent' in items:
|
||||
# parent can be a property
|
||||
continue
|
||||
@@ -40,8 +39,7 @@ def fast_parent_copy(obj):
|
||||
setattr(new_obj, key, new_elements[value])
|
||||
except KeyError:
|
||||
pass
|
||||
elif key in ['parent_stmt', 'parent_function', 'use_as_parent',
|
||||
'module']:
|
||||
elif key in ['parent_function', 'use_as_parent', 'module']:
|
||||
continue
|
||||
elif isinstance(value, list):
|
||||
setattr(new_obj, key, list_rec(value))
|
||||
|
||||
@@ -711,7 +711,7 @@ class Statement(Simple):
|
||||
|
||||
def get_code(self, new_line=True):
|
||||
def assemble(command_list, assignment=None):
|
||||
pieces = [c.get_code() if isinstance(c, Call) else c
|
||||
pieces = [c.get_code() if isinstance(c, Simple) else c
|
||||
for c in command_list]
|
||||
if assignment is None:
|
||||
return ''.join(pieces)
|
||||
@@ -1036,7 +1036,7 @@ class Array(Call):
|
||||
|
||||
def __init__(self, module, start_pos, arr_type=NOARRAY, parent=None, values=None):
|
||||
super(Array, self).__init__(module, None, arr_type, start_pos, parent)
|
||||
self.values = values if values else []
|
||||
self.values = values or []
|
||||
self.keys = []
|
||||
self.end_pos = None, None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user