mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
fix builtin module imports, fixes davidhalter/jedi-vim#152
This commit is contained in:
@@ -149,13 +149,18 @@ class ImportPath(pr.Base):
|
||||
Get the names of all modules in the search_path. This means file names
|
||||
and not names defined in the files.
|
||||
"""
|
||||
def generate_name(name):
|
||||
return pr.Name(self.GlobalNamespace, [(name, inf_pos)],
|
||||
inf_pos, inf_pos, self.import_stmt)
|
||||
|
||||
if not search_path:
|
||||
search_path = self.sys_path_with_modifications()
|
||||
names = []
|
||||
inf_pos = float('inf'), float('inf')
|
||||
for module_loader, name, is_pkg in pkgutil.iter_modules(search_path):
|
||||
inf_pos = (float('inf'), float('inf'))
|
||||
names.append(pr.Name(self.GlobalNamespace, [(name, inf_pos)],
|
||||
inf_pos, inf_pos, self.import_stmt))
|
||||
names.append(generate_name(name))
|
||||
# add builtin module names
|
||||
names += [generate_name(name) for name in sys.builtin_module_names]
|
||||
return names
|
||||
|
||||
def sys_path_with_modifications(self):
|
||||
|
||||
@@ -67,6 +67,10 @@ def scope_nested2():
|
||||
#? []
|
||||
import_tree.rename1
|
||||
|
||||
def builtin_test():
|
||||
#? ['math']
|
||||
import math
|
||||
|
||||
# -----------------
|
||||
# std lib modules
|
||||
# -----------------
|
||||
|
||||
Reference in New Issue
Block a user