1
0
forked from VimPlug/jedi

Fix get_parent_scope

This commit is contained in:
Dave Halter
2019-02-27 13:08:21 +01:00
parent 94f2677752
commit 17136e03d2
3 changed files with 8 additions and 5 deletions

View File

@@ -243,14 +243,16 @@ def get_parent_scope(node, include_flows=False):
Returns the underlying scope.
"""
scope = node.parent
if scope is None:
return None # It's a module already.
if scope.type in ('funcdef', 'classdef') and scope.name == node:
scope = scope.parent
if scope.parent is None: # The module scope.
return scope
while scope is not None:
if include_flows and isinstance(scope, tree.Flow):
while True:
if include_flows and isinstance(scope, tree.Flow) or is_scope(scope):
return scope
if is_scope(scope):
break
scope = scope.parent
return scope