diff --git a/jedi/api/project.py b/jedi/api/project.py index 6b76c8dc..ac70b26a 100644 --- a/jedi/api/project.py +++ b/jedi/api/project.py @@ -61,11 +61,13 @@ class Project(object): :param sys_path: list of str. You can override the sys path if you want. By default the ``sys.path.`` is generated from the environment (virtualenvs, etc). + :param added_sys_path: list of str. Adds these paths at the end of the + sys path. :param smart_sys_path: If this is enabled (default), adds paths from local directories. Otherwise you will have to rely on your packages being properly configured on the ``sys.path``. """ - def py2_comp(path, environment=None, sys_path=None, + def py2_comp(path, environment=None, sys_path=None, added_sys_path=True, smart_sys_path=True, _django=False): self._path = os.path.abspath(path) if isinstance(environment, SameEnvironment): @@ -74,6 +76,8 @@ class Project(object): self._sys_path = sys_path self._smart_sys_path = smart_sys_path self._django = _django + self.added_sys_path = [] + """The sys path that is going to be added at the end of the """ py2_comp(path, **kwargs) @@ -91,7 +95,7 @@ class Project(object): sys_path.remove('') except ValueError: pass - return sys_path + return sys_path + self.added_sys_path @inference_state_as_method_param_cache() def _get_sys_path(self, inference_state, environment=None, diff --git a/test/test_api/test_project.py b/test/test_api/test_project.py index f8bc8c60..7eeced4f 100644 --- a/test/test_api/test_project.py +++ b/test/test_api/test_project.py @@ -2,6 +2,7 @@ import os from ..helpers import get_example_dir, set_cwd, root_dir from jedi import Interpreter +from jedi.api import Project, get_default_project def test_django_default_project(Script): @@ -22,3 +23,10 @@ def test_interpreter_project_path(): with set_cwd(dir): project = Interpreter('', [locals()])._inference_state.project assert project._path == dir + + +def test_added_sys_path(inference_state): + project = get_default_project() + p = '/some_random_path' + project.added_sys_path = [p] + assert p in project._get_base_sys_path(inference_state)