From 9f41153eb28ce6d479922b9b2ea74ef765541c45 Mon Sep 17 00:00:00 2001 From: Aivar Annamaa Date: Sat, 23 Jan 2021 15:38:10 +0200 Subject: [PATCH] Allow tweaking Interpreter sys_path (#1734) --- jedi/api/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index 4cc94342..946f2c83 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -707,7 +707,7 @@ class Interpreter(Script): """ _allow_descriptor_getattr_default = True - def __init__(self, code, namespaces, **kwds): + def __init__(self, code, namespaces, *, project=None, **kwds): try: namespaces = [dict(n) for n in namespaces] except Exception: @@ -720,8 +720,11 @@ class Interpreter(Script): if not isinstance(environment, InterpreterEnvironment): raise TypeError("The environment needs to be an InterpreterEnvironment subclass.") - super().__init__(code, environment=environment, - project=Project(Path.cwd()), **kwds) + if project is None: + project = Project(Path.cwd()) + + super().__init__(code, environment=environment, project=project, **kwds) + self.namespaces = namespaces self._inference_state.allow_descriptor_getattr = self._allow_descriptor_getattr_default