forked from VimPlug/jedi
Fix nested comprehension contexts, fixes #1691
This commit is contained in:
@@ -255,8 +255,7 @@ class TreeContextMixin:
|
|||||||
if scope_node.type in ('funcdef', 'lambdef', 'classdef'):
|
if scope_node.type in ('funcdef', 'lambdef', 'classdef'):
|
||||||
return self.create_value(scope_node).as_context()
|
return self.create_value(scope_node).as_context()
|
||||||
elif scope_node.type in ('comp_for', 'sync_comp_for'):
|
elif scope_node.type in ('comp_for', 'sync_comp_for'):
|
||||||
parent_scope = parser_utils.get_parent_scope(scope_node)
|
parent_context = from_scope_node(parent_scope(scope_node.parent))
|
||||||
parent_context = from_scope_node(parent_scope)
|
|
||||||
if node.start_pos >= scope_node.children[-1].start_pos:
|
if node.start_pos >= scope_node.children[-1].start_pos:
|
||||||
return parent_context
|
return parent_context
|
||||||
return CompForContext(parent_context, scope_node)
|
return CompForContext(parent_context, scope_node)
|
||||||
|
|||||||
@@ -310,6 +310,13 @@ z = 3
|
|||||||
#< 10 (0,1), (0,10)
|
#< 10 (0,1), (0,10)
|
||||||
{z:1 for z in something}
|
{z:1 for z in something}
|
||||||
|
|
||||||
|
#< 8 (0,6), (0, 40)
|
||||||
|
[[x + nested_loopv2 for x in bar()] for nested_loopv2 in baz()]
|
||||||
|
|
||||||
|
#< 25 (0,20), (0, 65)
|
||||||
|
(("*" if abs(foo(x, nested_loopv1)) else " " for x in bar()) for nested_loopv1 in baz())
|
||||||
|
|
||||||
|
|
||||||
def whatever_func():
|
def whatever_func():
|
||||||
zzz = 3
|
zzz = 3
|
||||||
if UNDEFINED:
|
if UNDEFINED:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
"""
|
"""
|
||||||
|jedi| is mostly being tested by what I would call "integration tests". These
|
|jedi| is mostly being tested by what I would call "integration tests". These
|
||||||
tests are testing type inference with the public API. This makes a
|
tests are testing type inference with the public API. This makes a
|
||||||
|
|||||||
Reference in New Issue
Block a user