forked from VimPlug/jedi
Small sys path refactoring.
This commit is contained in:
@@ -252,10 +252,8 @@ class Importer(object):
|
||||
|
||||
def sys_path_with_modifications(self):
|
||||
in_path = []
|
||||
sys_path_mod = list(sys_path.sys_path_with_modifications(
|
||||
self._evaluator,
|
||||
self.module_context
|
||||
))
|
||||
sys_path_mod = self._evaluator.project.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
|
||||
|
||||
@@ -7,10 +7,12 @@ from jedi.cache import underscore_memoization
|
||||
|
||||
class Project(object):
|
||||
def __init__(self, sys_path=None):
|
||||
if sys_path is None:
|
||||
venv = os.getenv('VIRTUAL_ENV')
|
||||
if venv:
|
||||
sys_path = get_venv_path(venv)
|
||||
if sys_path is not None:
|
||||
self._sys_path = sys_path
|
||||
|
||||
venv = os.getenv('VIRTUAL_ENV')
|
||||
if venv:
|
||||
sys_path = get_venv_path(venv)
|
||||
|
||||
if sys_path is None:
|
||||
sys_path = sys.path
|
||||
|
||||
@@ -5,7 +5,7 @@ import imp
|
||||
from jedi.evaluate.site import addsitedir
|
||||
|
||||
from jedi._compatibility import unicode
|
||||
from jedi.evaluate.cache import evaluator_function_cache
|
||||
from jedi.evaluate.cache import evaluator_method_cache
|
||||
from jedi.evaluate.base_context import ContextualizedNode
|
||||
from jedi.evaluate.helpers import is_string
|
||||
from jedi import settings
|
||||
@@ -150,6 +150,7 @@ def _paths_from_list_modifications(module_context, trailer1, trailer2):
|
||||
yield abs_path
|
||||
|
||||
|
||||
@evaluator_method_cache(default=[])
|
||||
def check_sys_path_modifications(module_context):
|
||||
"""
|
||||
Detect sys.path modifications within module.
|
||||
@@ -187,7 +188,6 @@ def check_sys_path_modifications(module_context):
|
||||
return added
|
||||
|
||||
|
||||
@evaluator_function_cache(default=[])
|
||||
def sys_path_with_modifications(evaluator, module_context):
|
||||
return evaluator.project.sys_path + check_sys_path_modifications(module_context)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user