forked from VimPlug/jedi
Merge the implicit namespace improvement (pkgutils.itermodules modification)
There are still a few issues that need to be addressed.
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import sys
|
||||
import os
|
||||
import imp
|
||||
import pkgutil
|
||||
|
||||
from jedi._compatibility import find_module, cast_path, force_unicode
|
||||
from jedi._compatibility import find_module, cast_path, force_unicode, iter_modules
|
||||
from jedi.evaluate.compiled import access
|
||||
from jedi import parser_utils
|
||||
|
||||
@@ -71,7 +70,7 @@ def get_module_info(evaluator, sys_path=None, full_name=None, **kwargs):
|
||||
def list_module_names(evaluator, search_path):
|
||||
return [
|
||||
name
|
||||
for module_loader, name, is_pkg in pkgutil.iter_modules(search_path)
|
||||
for module_loader, name, is_pkg in iter_modules(search_path)
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import pkgutil
|
||||
import imp
|
||||
import re
|
||||
import os
|
||||
@@ -6,6 +5,7 @@ import os
|
||||
from parso import python_bytes_to_unicode
|
||||
|
||||
from jedi.evaluate.cache import evaluator_method_cache
|
||||
from jedi._compatibility import iter_modules
|
||||
from jedi.evaluate.filters import GlobalNameFilter, ContextNameMixin, \
|
||||
AbstractNameDefinition, ParserTreeFilter, DictFilter
|
||||
from jedi.evaluate import compiled
|
||||
@@ -188,7 +188,7 @@ class ModuleContext(TreeContext):
|
||||
path = self._path
|
||||
names = {}
|
||||
if path is not None and path.endswith(os.path.sep + '__init__.py'):
|
||||
mods = pkgutil.iter_modules([os.path.dirname(path)])
|
||||
mods = iter_modules([os.path.dirname(path)])
|
||||
for module_loader, name, is_pkg in mods:
|
||||
# It's obviously a relative import to the current module.
|
||||
names[name] = SubModuleName(self, name)
|
||||
|
||||
@@ -393,6 +393,7 @@ class Importer(object):
|
||||
and not names defined in the files.
|
||||
"""
|
||||
sub = self._evaluator.compiled_subprocess
|
||||
|
||||
names = []
|
||||
# add builtin module names
|
||||
if search_path is None and in_module is None:
|
||||
@@ -440,7 +441,7 @@ class Importer(object):
|
||||
# implicit namespace packages
|
||||
elif isinstance(context, ImplicitNamespaceContext):
|
||||
paths = context.paths
|
||||
names += self._get_module_names(paths)
|
||||
names += self._get_module_names(paths, in_module=context)
|
||||
|
||||
if only_modules:
|
||||
# In the case of an import like `from x.` we don't need to
|
||||
|
||||
Reference in New Issue
Block a user