1
0
forked from VimPlug/jedi

Try to put all module loading in one place including namespace packages

This commit is contained in:
Dave Halter
2018-02-12 20:49:45 +01:00
parent 9fec494e84
commit a33cbc8ae3

View File

@@ -367,15 +367,9 @@ class Importer(object):
_add_error(self.module_context, import_path[-1]) _add_error(self.module_context, import_path[-1])
return NO_CONTEXTS return NO_CONTEXTS
if isinstance(module_path, ImplicitNSInfo): module = _load_module(
from jedi.evaluate.context.namespace import ImplicitNamespaceContext self._evaluator, module_path, code, sys_path, parent_module
module = ImplicitNamespaceContext(
self._evaluator,
fullname=module_path.name,
paths=module_path.paths,
) )
else:
module = _load_module(self._evaluator, module_path, code, sys_path, parent_module)
if module is None: if module is None:
# The file might raise an ImportError e.g. and therefore not be # The file might raise an ImportError e.g. and therefore not be
@@ -473,6 +467,14 @@ class Importer(object):
def _load_module(evaluator, path=None, code=None, sys_path=None, parent_module=None): def _load_module(evaluator, path=None, code=None, sys_path=None, parent_module=None):
if isinstance(path, ImplicitNSInfo):
from jedi.evaluate.context.namespace import ImplicitNamespaceContext
module = ImplicitNamespaceContext(
evaluator,
fullname=path.name,
paths=path.paths,
)
else:
if sys_path is None: if sys_path is None:
sys_path = evaluator.get_sys_path() sys_path = evaluator.get_sys_path()