forked from VimPlug/jedi
Remove some code that is not necessary anmore, because of an improvment in get_parent_scope
This commit is contained in:
@@ -8,7 +8,7 @@ from contextlib import contextmanager
|
|||||||
from parso.python import tree
|
from parso.python import tree
|
||||||
|
|
||||||
from jedi._compatibility import unicode
|
from jedi._compatibility import unicode
|
||||||
from jedi.parser_utils import get_parent_scope, is_name_of_func_or_class_def
|
from jedi.parser_utils import get_parent_scope
|
||||||
|
|
||||||
|
|
||||||
def is_stdlib_path(path):
|
def is_stdlib_path(path):
|
||||||
@@ -175,21 +175,6 @@ def get_module_names(module, all_scopes):
|
|||||||
|
|
||||||
def is_module_scope_name(name):
|
def is_module_scope_name(name):
|
||||||
parent_scope = get_parent_scope(name)
|
parent_scope = get_parent_scope(name)
|
||||||
if is_name_of_func_or_class_def(name, parent_scope):
|
|
||||||
# XXX: In syntax tree function- and class-name nodes are immediate children of
|
|
||||||
# their respective class-definition or function-definition nodes. Technically,
|
|
||||||
# get_parent_scope(...) for them should return the parent of the definition node,
|
|
||||||
# because
|
|
||||||
#
|
|
||||||
# def foo(...): pass
|
|
||||||
#
|
|
||||||
# is equivalent to
|
|
||||||
#
|
|
||||||
# foo = lambda(...): None
|
|
||||||
#
|
|
||||||
# but that would be a big change that could break type inference, whereas for now
|
|
||||||
# this discrepancy looks like only a problem for "get_module_names".
|
|
||||||
parent_scope = parent_scope.parent
|
|
||||||
# async functions have an extra wrapper. Strip it.
|
# async functions have an extra wrapper. Strip it.
|
||||||
if parent_scope and parent_scope.type == 'async_stmt':
|
if parent_scope and parent_scope.type == 'async_stmt':
|
||||||
parent_scope = parent_scope.parent
|
parent_scope = parent_scope.parent
|
||||||
|
|||||||
@@ -242,14 +242,6 @@ def is_scope(node):
|
|||||||
return node.type in ('file_input', 'classdef', 'funcdef', 'lambdef', 'comp_for')
|
return node.type in ('file_input', 'classdef', 'funcdef', 'lambdef', 'comp_for')
|
||||||
|
|
||||||
|
|
||||||
def is_name_of_func_or_class_def(name_node, func_or_class_def_node):
|
|
||||||
"""Return True if name_node is the name of the func_or_class_def_node."""
|
|
||||||
return (
|
|
||||||
name_node.parent is func_or_class_def_node and
|
|
||||||
name_node.type == 'name' and
|
|
||||||
func_or_class_def_node.type in ('classdef', 'funcdef'))
|
|
||||||
|
|
||||||
|
|
||||||
def get_parent_scope(node, include_flows=False):
|
def get_parent_scope(node, include_flows=False):
|
||||||
"""
|
"""
|
||||||
Returns the underlying scope.
|
Returns the underlying scope.
|
||||||
|
|||||||
Reference in New Issue
Block a user