mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 14:54:47 +08:00
generator basics - but not yet working with next, etc. need the bultins therefore
This commit is contained in:
17
evaluate.py
17
evaluate.py
@@ -7,7 +7,6 @@ follow_statement -> follow_call -> follow_paths -> follow_path
|
|||||||
TODO doc
|
TODO doc
|
||||||
TODO list comprehensions, priority?
|
TODO list comprehensions, priority?
|
||||||
TODO evaluate asserts (type safety)
|
TODO evaluate asserts (type safety)
|
||||||
TODO generators
|
|
||||||
|
|
||||||
python 3 stuff:
|
python 3 stuff:
|
||||||
TODO class decorators
|
TODO class decorators
|
||||||
@@ -392,7 +391,7 @@ class Execution(Executable):
|
|||||||
return func
|
return func
|
||||||
|
|
||||||
@memoize_default(default=[])
|
@memoize_default(default=[])
|
||||||
def get_return_types(self):
|
def get_return_types(self, evaluate_generator=False):
|
||||||
"""
|
"""
|
||||||
Get the return vars of a function.
|
Get the return vars of a function.
|
||||||
"""
|
"""
|
||||||
@@ -408,6 +407,9 @@ class Execution(Executable):
|
|||||||
# don't do this with exceptions, as usual, because some deeper
|
# don't do this with exceptions, as usual, because some deeper
|
||||||
# exceptions could be catched - and I wouldn't know what happened.
|
# exceptions could be catched - and I wouldn't know what happened.
|
||||||
if hasattr(func, 'returns'):
|
if hasattr(func, 'returns'):
|
||||||
|
if func.is_generator:
|
||||||
|
return [Generator(func)]
|
||||||
|
else:
|
||||||
self.set_param_cb(func)
|
self.set_param_cb(func)
|
||||||
self.base.is_decorated = True
|
self.base.is_decorated = True
|
||||||
ret = func.returns
|
ret = func.returns
|
||||||
@@ -435,6 +437,17 @@ class Execution(Executable):
|
|||||||
(self.__class__.__name__, self.base)
|
(self.__class__.__name__, self.base)
|
||||||
|
|
||||||
|
|
||||||
|
class Generator(object):
|
||||||
|
def __init__(self, execution):
|
||||||
|
super(Generator, self).__init__()
|
||||||
|
self.execution = execution
|
||||||
|
|
||||||
|
def get_defined_names(self):
|
||||||
|
return []
|
||||||
|
# TODO add generator names (__next__, send, close, throw, next?)
|
||||||
|
#self.execution.get_return_types()
|
||||||
|
|
||||||
|
|
||||||
class Array(object):
|
class Array(object):
|
||||||
"""
|
"""
|
||||||
Used as a mirror to parsing.Array, if needed. It defines some getter
|
Used as a mirror to parsing.Array, if needed. It defines some getter
|
||||||
|
|||||||
@@ -237,4 +237,5 @@ def gen():
|
|||||||
yield ""
|
yield ""
|
||||||
|
|
||||||
exe = gen()
|
exe = gen()
|
||||||
exe.
|
#? ['upper']
|
||||||
|
exe.upper
|
||||||
|
|||||||
Reference in New Issue
Block a user