mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 06:24:27 +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
|
Get the names of all modules in the search_path. This means file names
|
||||||
and not names defined in the files.
|
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:
|
if not search_path:
|
||||||
search_path = self.sys_path_with_modifications()
|
search_path = self.sys_path_with_modifications()
|
||||||
names = []
|
names = []
|
||||||
|
inf_pos = float('inf'), float('inf')
|
||||||
for module_loader, name, is_pkg in pkgutil.iter_modules(search_path):
|
for module_loader, name, is_pkg in pkgutil.iter_modules(search_path):
|
||||||
inf_pos = (float('inf'), float('inf'))
|
names.append(generate_name(name))
|
||||||
names.append(pr.Name(self.GlobalNamespace, [(name, inf_pos)],
|
# add builtin module names
|
||||||
inf_pos, inf_pos, self.import_stmt))
|
names += [generate_name(name) for name in sys.builtin_module_names]
|
||||||
return names
|
return names
|
||||||
|
|
||||||
def sys_path_with_modifications(self):
|
def sys_path_with_modifications(self):
|
||||||
|
|||||||
@@ -67,6 +67,10 @@ def scope_nested2():
|
|||||||
#? []
|
#? []
|
||||||
import_tree.rename1
|
import_tree.rename1
|
||||||
|
|
||||||
|
def builtin_test():
|
||||||
|
#? ['math']
|
||||||
|
import math
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# std lib modules
|
# std lib modules
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
Reference in New Issue
Block a user