mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Infer names in the correct way, fixes #1286
This commit is contained in:
@@ -21,6 +21,7 @@ from jedi.evaluate.pep0484 import _evaluate_for_annotation
|
||||
from jedi.evaluate.context import ClassContext, FunctionContext
|
||||
from jedi.evaluate.context import iterable
|
||||
from jedi.evaluate.context import TreeInstance, CompiledInstance
|
||||
from jedi.evaluate.filters import TreeNameDefinition, ParamName
|
||||
from jedi.evaluate.finder import NameFinder
|
||||
from jedi.evaluate.helpers import is_string, is_literal, is_number, is_compiled
|
||||
from jedi.evaluate.compiled.access import COMPARISON_OPERATORS
|
||||
@@ -526,8 +527,11 @@ def tree_name_to_contexts(evaluator, context, tree_name):
|
||||
# which means the function itself.
|
||||
filters = [next(filters)]
|
||||
return finder.find(filters, attribute_lookup=False)
|
||||
elif node.type == 'param':
|
||||
raise NotImplementedError
|
||||
elif node.type not in ('import_from', 'import_name'):
|
||||
raise ValueError("Should not happen. type: %s", node.type)
|
||||
context = evaluator.create_context(context, tree_name)
|
||||
return eval_atom(context, tree_name)
|
||||
|
||||
typ = node.type
|
||||
if typ == 'for_stmt':
|
||||
|
||||
@@ -96,3 +96,8 @@ def test_names_twice(environment):
|
||||
|
||||
defs = names(source=source, environment=environment)
|
||||
assert defs[0].defined_names() == []
|
||||
|
||||
|
||||
def test_simple_name(environment):
|
||||
defs = names('foo', references=True, environment=environment)
|
||||
assert not defs[0]._name.infer()
|
||||
|
||||
Reference in New Issue
Block a user