mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
generators can now be indexed, don't know if this is a good thing. however, it fixes some problems with lists
This commit is contained in:
@@ -661,6 +661,11 @@ class Generator(object):
|
|||||||
return self.func.parent
|
return self.func.parent
|
||||||
#self.execution.get_return_types()
|
#self.execution.get_return_types()
|
||||||
|
|
||||||
|
def get_index_types(self, index):
|
||||||
|
# TODO check if this method is right here, this means that Generators
|
||||||
|
# can be indexed, which is not the Python way.
|
||||||
|
return Execution(self.func).get_return_types(True)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<%s of %s>" % (self.__class__.__name__, self.func)
|
return "<%s of %s>" % (self.__class__.__name__, self.func)
|
||||||
|
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ def complete(source, row, column, source_path):
|
|||||||
if not isinstance(s, evaluate.Function):
|
if not isinstance(s, evaluate.Function):
|
||||||
completions += s.get_defined_names()
|
completions += s.get_defined_names()
|
||||||
|
|
||||||
|
#completions[0].
|
||||||
completions = [c for c in completions
|
completions = [c for c in completions
|
||||||
if c.names[-1].lower().startswith(like.lower())]
|
if c.names[-1].lower().startswith(like.lower())]
|
||||||
|
|
||||||
|
|||||||
@@ -173,21 +173,3 @@ exe[3].items
|
|||||||
#? set()
|
#? set()
|
||||||
exe[3]['c']
|
exe[3]['c']
|
||||||
|
|
||||||
# -----------------
|
|
||||||
# generators
|
|
||||||
# -----------------
|
|
||||||
|
|
||||||
def gen():
|
|
||||||
yield 1
|
|
||||||
yield ""
|
|
||||||
|
|
||||||
gen_exe = gen()
|
|
||||||
#? ['upper']
|
|
||||||
next(gen_exe).upper
|
|
||||||
#? ['real']
|
|
||||||
next(gen_exe).real
|
|
||||||
#? int() str()
|
|
||||||
next(gen_exe)
|
|
||||||
|
|
||||||
#? int() str() list
|
|
||||||
next(gen_exe, list)
|
|
||||||
|
|||||||
32
test/completion/generators.py
Normal file
32
test/completion/generators.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# -----------------
|
||||||
|
# yield statement
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
def gen():
|
||||||
|
yield 1
|
||||||
|
yield ""
|
||||||
|
|
||||||
|
gen_exe = gen()
|
||||||
|
#? ['upper']
|
||||||
|
next(gen_exe).upper
|
||||||
|
#? ['real']
|
||||||
|
next(gen_exe).real
|
||||||
|
#? int() str()
|
||||||
|
next(gen_exe)
|
||||||
|
|
||||||
|
#? int() str() list
|
||||||
|
next(gen_exe, list)
|
||||||
|
|
||||||
|
# -----------------
|
||||||
|
# generators should be indexable?
|
||||||
|
# -----------------
|
||||||
|
def get(self):
|
||||||
|
yield 1
|
||||||
|
yield ""
|
||||||
|
|
||||||
|
arr = []
|
||||||
|
for a in arr:
|
||||||
|
arr += get()
|
||||||
|
|
||||||
|
#? int() str()
|
||||||
|
arr[0].
|
||||||
Reference in New Issue
Block a user