1
0
forked from VimPlug/jedi

Small sys path refactoring.

This commit is contained in:
Dave Halter
2017-10-06 09:01:15 +02:00
parent 21531abd1e
commit 8dba08eeb2
3 changed files with 10 additions and 10 deletions

View File

@@ -252,10 +252,8 @@ class Importer(object):
def sys_path_with_modifications(self): def sys_path_with_modifications(self):
in_path = [] in_path = []
sys_path_mod = list(sys_path.sys_path_with_modifications( sys_path_mod = self._evaluator.project.sys_path \
self._evaluator, + sys_path.check_sys_path_modifications(self.module_context)
self.module_context
))
if self.file_path is not None: if self.file_path is not None:
# If you edit e.g. gunicorn, there will be imports like this: # If you edit e.g. gunicorn, there will be imports like this:
# `from gunicorn import something`. But gunicorn is not in the # `from gunicorn import something`. But gunicorn is not in the

View File

@@ -7,7 +7,9 @@ from jedi.cache import underscore_memoization
class Project(object): class Project(object):
def __init__(self, sys_path=None): def __init__(self, sys_path=None):
if sys_path is None: if sys_path is not None:
self._sys_path = sys_path
venv = os.getenv('VIRTUAL_ENV') venv = os.getenv('VIRTUAL_ENV')
if venv: if venv:
sys_path = get_venv_path(venv) sys_path = get_venv_path(venv)

View File

@@ -5,7 +5,7 @@ import imp
from jedi.evaluate.site import addsitedir from jedi.evaluate.site import addsitedir
from jedi._compatibility import unicode 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.base_context import ContextualizedNode
from jedi.evaluate.helpers import is_string from jedi.evaluate.helpers import is_string
from jedi import settings from jedi import settings
@@ -150,6 +150,7 @@ def _paths_from_list_modifications(module_context, trailer1, trailer2):
yield abs_path yield abs_path
@evaluator_method_cache(default=[])
def check_sys_path_modifications(module_context): def check_sys_path_modifications(module_context):
""" """
Detect sys.path modifications within module. Detect sys.path modifications within module.
@@ -187,7 +188,6 @@ def check_sys_path_modifications(module_context):
return added return added
@evaluator_function_cache(default=[])
def sys_path_with_modifications(evaluator, module_context): def sys_path_with_modifications(evaluator, module_context):
return evaluator.project.sys_path + check_sys_path_modifications(module_context) return evaluator.project.sys_path + check_sys_path_modifications(module_context)