Allow tweaking Interpreter sys_path (#1734)

This commit is contained in:
Aivar Annamaa
2021-01-23 15:38:10 +02:00
committed by GitHub
parent 387d73990b
commit 9f41153eb2

View File

@@ -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