mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 23:34:45 +08:00
iter replaces __iter__ calls
This commit is contained in:
10
evaluate.py
10
evaluate.py
@@ -9,6 +9,7 @@ TODO nonlocal statement
|
|||||||
TODO doc
|
TODO doc
|
||||||
TODO list comprehensions, priority?
|
TODO list comprehensions, priority?
|
||||||
TODO care for *args **kwargs
|
TODO care for *args **kwargs
|
||||||
|
TODO annotations
|
||||||
"""
|
"""
|
||||||
from _compatibility import next
|
from _compatibility import next
|
||||||
|
|
||||||
@@ -85,7 +86,8 @@ class Executable(object):
|
|||||||
result.append(self_name)
|
result.append(self_name)
|
||||||
# There may be calls, which don't fit all the params, this just ignores
|
# There may be calls, which don't fit all the params, this just ignores
|
||||||
# it.
|
# it.
|
||||||
for i, value in enumerate(self.params, offset):
|
param_iterator = iter(self.params)
|
||||||
|
for i, value in enumerate(param_iterator, offset):
|
||||||
try:
|
try:
|
||||||
param = self.func.params[i]
|
param = self.func.params[i]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
@@ -98,7 +100,7 @@ class Executable(object):
|
|||||||
new_param._assignment_calls = calls
|
new_param._assignment_calls = calls
|
||||||
name = copy.copy(param.get_name())
|
name = copy.copy(param.get_name())
|
||||||
name.parent = new_param
|
name.parent = new_param
|
||||||
#print 'insert', i, name, calls.values, value, self.func.params
|
print 'insert', i, name, calls.values, value, self.func.params
|
||||||
result.append(name)
|
result.append(name)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -455,7 +457,7 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
|
|||||||
names = get_defined_names_for_position(scope, position)
|
names = get_defined_names_for_position(scope, position)
|
||||||
else:
|
else:
|
||||||
names = scope.get_defined_names()
|
names = scope.get_defined_names()
|
||||||
scope_generator = [(scope, names)].__iter__()
|
scope_generator = iter([(scope, names)])
|
||||||
#print ' ln', position
|
#print ' ln', position
|
||||||
|
|
||||||
return remove_statements(filter_name(scope_generator))
|
return remove_statements(filter_name(scope_generator))
|
||||||
@@ -674,7 +676,7 @@ def follow_import(_import):
|
|||||||
|
|
||||||
scope, rest = modules.find_module(loaded_in, ns_list)
|
scope, rest = modules.find_module(loaded_in, ns_list)
|
||||||
if rest:
|
if rest:
|
||||||
scopes = follow_path(rest.__iter__(), scope)
|
scopes = follow_path(iter(rest), scope)
|
||||||
else:
|
else:
|
||||||
scopes = [scope]
|
scopes = [scope]
|
||||||
|
|
||||||
|
|||||||
36
parsetest.py
36
parsetest.py
@@ -158,23 +158,23 @@ a = 3; b = ""
|
|||||||
b,a=a,b
|
b,a=a,b
|
||||||
a.
|
a.
|
||||||
|
|
||||||
class SuperClass(object):
|
|
||||||
super_class = 3
|
|
||||||
def __init__(self):
|
|
||||||
self.super_var = ''
|
|
||||||
def super_method(self)
|
|
||||||
self.super_var2 = list
|
|
||||||
class Mixin(SuperClass):
|
|
||||||
def super_method(self):
|
|
||||||
return int
|
|
||||||
class SubClass(Mixin, SuperClass):
|
|
||||||
sub_class = 3
|
|
||||||
def __init__(self):
|
|
||||||
self.sub_var = ''
|
|
||||||
def sub_method(self):
|
|
||||||
self.sub_var2 = list
|
|
||||||
return tuple
|
|
||||||
instance = SubClass()
|
|
||||||
|
|
||||||
|
|
||||||
SubClass.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def args_func(arg1, *args):
|
||||||
|
return args
|
||||||
|
|
||||||
|
#? ['real']
|
||||||
|
args_func(1,"")[0].real
|
||||||
|
|||||||
@@ -848,9 +848,9 @@ class Array(Call):
|
|||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
if self.type == self.DICT:
|
if self.type == self.DICT:
|
||||||
return self.values.items().__iter__()
|
return iter(self.values.items())
|
||||||
else:
|
else:
|
||||||
return self.values.__iter__()
|
return iter(self.values)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
if self.type == self.NOARRAY:
|
if self.type == self.NOARRAY:
|
||||||
|
|||||||
@@ -67,3 +67,13 @@ def a():
|
|||||||
func_b
|
func_b
|
||||||
#? ['real']
|
#? ['real']
|
||||||
l.real
|
l.real
|
||||||
|
|
||||||
|
# -----------------
|
||||||
|
# *args / ** kwargs
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
def args_func(*args):
|
||||||
|
return args
|
||||||
|
|
||||||
|
#? ['real']
|
||||||
|
args_func(1)[0].real
|
||||||
|
|||||||
Reference in New Issue
Block a user