mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-10 07:41:51 +08:00
Fix Definition.names for star import
This commit is contained in:
@@ -296,7 +296,10 @@ class Definition(BaseDefinition):
|
||||
elif isinstance(d, pr.Module):
|
||||
return [self.module_name]
|
||||
elif isinstance(d, pr.Import):
|
||||
return [n.names[-1] for n in d.get_defined_names()]
|
||||
try:
|
||||
return [n.names[-1] for n in d.get_defined_names()]
|
||||
except AttributeError:
|
||||
pass
|
||||
elif isinstance(d, pr.Statement):
|
||||
try:
|
||||
return [a.values[0][0].name.names[-1]
|
||||
|
||||
@@ -415,6 +415,17 @@ class TestGetDefinitions(TestBase):
|
||||
assert len(definitions) == 1
|
||||
assert definitions[0].names == ['x', 'y']
|
||||
|
||||
def test_multiple_imports(self):
|
||||
definitions = api.get_definitions("""
|
||||
from module import a, b
|
||||
from another_module import *
|
||||
""")
|
||||
assert len(definitions) == 3
|
||||
assert definitions[0].names == ['a']
|
||||
assert definitions[1].names == ['b']
|
||||
assert definitions[2].names == []
|
||||
|
||||
|
||||
class TestSpeed(TestBase):
|
||||
def _check_speed(time_per_run, number=4, run_warm=True):
|
||||
""" Speed checks should typically be very tolerant. Some machines are
|
||||
|
||||
Reference in New Issue
Block a user