mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Allow tweaking Interpreter sys_path (#1734)
This commit is contained in:
@@ -707,7 +707,7 @@ class Interpreter(Script):
|
|||||||
"""
|
"""
|
||||||
_allow_descriptor_getattr_default = True
|
_allow_descriptor_getattr_default = True
|
||||||
|
|
||||||
def __init__(self, code, namespaces, **kwds):
|
def __init__(self, code, namespaces, *, project=None, **kwds):
|
||||||
try:
|
try:
|
||||||
namespaces = [dict(n) for n in namespaces]
|
namespaces = [dict(n) for n in namespaces]
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -720,8 +720,11 @@ class Interpreter(Script):
|
|||||||
if not isinstance(environment, InterpreterEnvironment):
|
if not isinstance(environment, InterpreterEnvironment):
|
||||||
raise TypeError("The environment needs to be an InterpreterEnvironment subclass.")
|
raise TypeError("The environment needs to be an InterpreterEnvironment subclass.")
|
||||||
|
|
||||||
super().__init__(code, environment=environment,
|
if project is None:
|
||||||
project=Project(Path.cwd()), **kwds)
|
project = Project(Path.cwd())
|
||||||
|
|
||||||
|
super().__init__(code, environment=environment, project=project, **kwds)
|
||||||
|
|
||||||
self.namespaces = namespaces
|
self.namespaces = namespaces
|
||||||
self._inference_state.allow_descriptor_getattr = self._allow_descriptor_getattr_default
|
self._inference_state.allow_descriptor_getattr = self._allow_descriptor_getattr_default
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user