1
0
forked from VimPlug/jedi

Some simplifications

This commit is contained in:
Dave Halter
2018-02-16 10:21:43 +01:00
parent fa9364307f
commit 30cfdee325

View File

@@ -258,27 +258,28 @@ class Importer(object):
"""Returns the import path as pure strings instead of `Name`."""
return tuple(
name.value if isinstance(name, tree.Name) else name
for name in self.import_path)
for name in self.import_path
)
def sys_path_with_modifications(self):
in_path = []
sys_path_mod = self._evaluator.get_sys_path() \
+ sys_path.check_sys_path_modifications(self.module_context)
if self.file_path is not None:
# If you edit e.g. gunicorn, there will be imports like this:
# `from gunicorn import something`. But gunicorn is not in the
# sys.path. Therefore look if gunicorn is a parent directory, #56.
if self.import_path: # TODO is this check really needed?
if self.import_path:
for path in sys_path.traverse_parents(self.file_path):
if os.path.basename(path) == self.str_import_path[0]:
in_path.append(force_unicode(os.path.dirname(path)))
sys_path_mod.insert(0, force_unicode(os.path.dirname(path)))
break
# Since we know nothing about the call location of the sys.path,
# it's a possibility that the current directory is the origin of
# the Python execution.
sys_path_mod.append(force_unicode(os.path.dirname(self.file_path)))
return in_path + sys_path_mod
return sys_path_mod
def follow(self):
if not self.import_path: