1
0
forked from VimPlug/jedi

Make generators return more correct values with while loops, fixes #683

This commit is contained in:
Dave Halter
2020-01-29 10:13:46 +01:00
parent d630ed55f3
commit e930f47861
4 changed files with 13 additions and 8 deletions
+7 -5
View File
@@ -3,8 +3,10 @@ from jedi.common.utils import monkeypatch
class AbstractLazyValue(object):
def __init__(self, data):
def __init__(self, data, min=1, max=1):
self.data = data
self.min = min
self.max = max
def __repr__(self):
return '<%s: %s>' % (self.__class__.__name__, self.data)
@@ -26,16 +28,16 @@ class LazyKnownValues(AbstractLazyValue):
class LazyUnknownValue(AbstractLazyValue):
def __init__(self):
super(LazyUnknownValue, self).__init__(None)
def __init__(self, min=1, max=1):
super(LazyUnknownValue, self).__init__(None, min, max)
def infer(self):
return NO_VALUES
class LazyTreeValue(AbstractLazyValue):
def __init__(self, context, node):
super(LazyTreeValue, self).__init__(node)
def __init__(self, context, node, min=1, max=1):
super(LazyTreeValue, self).__init__(node, min, max)
self.context = context
# We need to save the predefined names. It's an unfortunate side effect
# that needs to be tracked otherwise results will be wrong.