1
0
forked from VimPlug/jedi

WIP import improvement, getting rid of bad old code

This commit is contained in:
Dave Halter
2019-03-21 23:22:19 +01:00
parent 151935dc67
commit b6612a83c3
10 changed files with 129 additions and 111 deletions

View File

@@ -150,15 +150,21 @@ class Script(object):
@cache.memoize_method
def _get_module(self):
names = ('__main__',)
is_package = False
if self.path is not None:
import_names = transform_path_to_dotted(self._evaluator.get_sys_path(), self.path)
import_names, is_p = transform_path_to_dotted(
self._evaluator.get_sys_path(),
self.path
)
if import_names is not None:
names = import_names
is_package = is_p
module = ModuleContext(
self._evaluator, self._module_node, cast_path(self.path),
string_names=names,
code_lines=self._code_lines,
is_package=is_package,
)
self._evaluator.module_cache.add(names, ContextSet([module]))
return module