1
0
forked from VimPlug/jedi

again testing improvements. follow_definitions imports are now pretty much covered

This commit is contained in:
Dave Halter
2014-03-21 13:50:29 +01:00
parent eeeeee49f5
commit fa0502d762
3 changed files with 73 additions and 17 deletions

View File

@@ -266,6 +266,31 @@ class Importer(object):
return in_path + sys_path.sys_path_with_modifications(self.module)
def follow(self, evaluator):
try:
scope, rest = self._importer.follow_file_system()
except ModuleNotFound:
debug.warning('Module not found: %s', self.import_stmt)
return []
scopes = [scope]
scopes += remove_star_imports(self._evaluator, scope)
# follow the rest of the import (not FS -> classes, functions)
if len(rest) > 1 or rest and self.is_like_search:
scopes = []
if ['os', 'path'] == self.import_path[:2] \
and not self._is_relative_import():
# This is a huge exception, we follow a nested import
# ``os.path``, because it's a very important one in Python
# that is being achieved by messing with ``sys.modules`` in
# ``os``.
scopes = self._evaluator.follow_path(iter(rest), [scope], scope)
elif rest:
scopes = itertools.chain.from_iterable(
self._evaluator.follow_path(iter(rest), [s], s)
for s in scopes)
def follow_file_system(self):
if self.file_path:
sys_path_mod = list(self.sys_path_with_modifications())