mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Fix a bug in call_of_name.
It was possible to get a NAME(x) result when calling call_of_name on x, which shouldn't happen. It should just return x.
This commit is contained in:
@@ -86,6 +86,9 @@ def call_of_name(name, cut_own_trailer=False):
|
||||
par = name
|
||||
if tree.is_node(par.parent, 'trailer'):
|
||||
par = par.parent
|
||||
if par.children[0] in ('(', '['):
|
||||
# The trailer is not a NAME.NAME trailer, but a call to something.
|
||||
return name
|
||||
|
||||
power = par.parent
|
||||
if tree.is_node(power, 'power') and power.children[0] != name \
|
||||
|
||||
16
test/test_evaluate/test_helpers.py
Normal file
16
test/test_evaluate/test_helpers.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from textwrap import dedent
|
||||
|
||||
from jedi import names
|
||||
from jedi.evaluate import helpers
|
||||
|
||||
|
||||
def test_call_of_name_in_brackets():
|
||||
s = dedent("""
|
||||
x = 1
|
||||
type(x)
|
||||
""")
|
||||
last_x = names(s, references=True, definitions=False)[-1]
|
||||
name = last_x._name
|
||||
|
||||
call = helpers.call_of_name(name)
|
||||
assert call == name
|
||||
Reference in New Issue
Block a user