Comprehenions can also define self variables.

Also related to #932.
This commit is contained in:
Dave Halter
2017-09-09 20:20:05 +02:00
parent 40f4f032c6
commit c7f225439d
2 changed files with 10 additions and 0 deletions

View File

@@ -189,6 +189,9 @@ class AbstractInstanceContext(Context):
elif scope.type == 'classdef':
class_context = er.ClassContext(self.evaluator, scope, parent_context)
return class_context
elif scope.type == 'comp_for':
# Comprehensions currently don't have a special scope in Jedi.
return self.create_instance_context(class_context, scope)
else:
raise NotImplementedError
return class_context

View File

@@ -526,3 +526,10 @@ class Foo(object):
Foo().create_class().a
#? float()
Foo().b
class Foo(object):
def comprehension_definition(self):
return [1 for self.b in [1]]
#? int()
Foo().b