forked from VimPlug/jedi
Make sure that del_stmt as a name can be handled, see #313
This commit is contained in:
@@ -64,6 +64,11 @@ def filter_names(inference_state, completion_names, stack, like_name, fuzzy, cac
|
|||||||
k = (new.name, new.complete) # key
|
k = (new.name, new.complete) # key
|
||||||
if k not in comp_dct:
|
if k not in comp_dct:
|
||||||
comp_dct.add(k)
|
comp_dct.add(k)
|
||||||
|
tree_name = name.tree_name
|
||||||
|
if tree_name is not None:
|
||||||
|
definition = tree_name.get_definition()
|
||||||
|
if definition is not None and definition.type == 'del_stmt':
|
||||||
|
continue
|
||||||
yield new
|
yield new
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ from parso.python.tree import Name
|
|||||||
|
|
||||||
from jedi import settings
|
from jedi import settings
|
||||||
from jedi.inference.arguments import TreeArguments
|
from jedi.inference.arguments import TreeArguments
|
||||||
from jedi.inference import helpers
|
|
||||||
from jedi.inference.value import iterable
|
from jedi.inference.value import iterable
|
||||||
from jedi.inference.base_value import NO_VALUES
|
from jedi.inference.base_value import NO_VALUES
|
||||||
from jedi.parser_utils import is_scope
|
from jedi.parser_utils import is_scope
|
||||||
@@ -38,7 +37,17 @@ def filter_name(filters, name_or_str):
|
|||||||
if names:
|
if names:
|
||||||
break
|
break
|
||||||
|
|
||||||
return list(names)
|
return list(_remove_del_stmt(names))
|
||||||
|
|
||||||
|
|
||||||
|
def _remove_del_stmt(names):
|
||||||
|
# Catch del statements and remove them from results.
|
||||||
|
for name in names:
|
||||||
|
if name.tree_name is not None:
|
||||||
|
definition = name.tree_name.get_definition()
|
||||||
|
if definition is not None and definition.type == 'del_stmt':
|
||||||
|
continue
|
||||||
|
yield name
|
||||||
|
|
||||||
|
|
||||||
def check_flow_information(value, flow, search_name, pos):
|
def check_flow_information(value, flow, search_name, pos):
|
||||||
|
|||||||
@@ -725,7 +725,9 @@ def tree_name_to_values(inference_state, context, tree_name):
|
|||||||
# the static analysis report.
|
# the static analysis report.
|
||||||
exceptions = context.infer_node(tree_name.get_previous_sibling().get_previous_sibling())
|
exceptions = context.infer_node(tree_name.get_previous_sibling().get_previous_sibling())
|
||||||
types = exceptions.execute_with_values()
|
types = exceptions.execute_with_values()
|
||||||
elif node.type == 'param':
|
elif typ == 'param':
|
||||||
|
types = NO_VALUES
|
||||||
|
elif typ == 'del_stmt':
|
||||||
types = NO_VALUES
|
types = NO_VALUES
|
||||||
else:
|
else:
|
||||||
raise ValueError("Should not happen. type: %s" % typ)
|
raise ValueError("Should not happen. type: %s" % typ)
|
||||||
|
|||||||
@@ -203,6 +203,19 @@ if r:
|
|||||||
#? int()
|
#? int()
|
||||||
r
|
r
|
||||||
|
|
||||||
|
# -----------------
|
||||||
|
# del
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
deleted_var = 3
|
||||||
|
del deleted_var
|
||||||
|
#? int()
|
||||||
|
deleted_var
|
||||||
|
#? ['deleted_var']
|
||||||
|
deleted_var
|
||||||
|
#! ['deleted_var = 3']
|
||||||
|
deleted_var
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# within docstrs
|
# within docstrs
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
Reference in New Issue
Block a user