Skip to content

Commit b0174b7

Browse files
committed
Use jedi Interpreter and preload installed packages
1 parent 6dd41c1 commit b0174b7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pyls/workspace.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def __init__(self, uri, workspace, source=None, version=None, local=True, extra_
133133

134134
jedi.settings.cache_directory = '.cache/jedi/'
135135
jedi.settings.use_filesystem_cache = True
136+
jedi.settings.auto_import_modules = ['numpy', 'pandas', 'scipy', 'matplotlib', 'scikit-learn', 'requests' ]
136137

137138
def __str__(self):
138139
return str(self.uri)
@@ -237,19 +238,21 @@ def jedi_script(self, position=None):
237238
environment = self.get_enviroment(environment_path) if environment_path else None
238239
sys_path = self.sys_path(environment_path) + extra_paths
239240
project_path = self._workspace.root_path
241+
import __main__
240242

241243
kwargs = {
242244
'code': self.source,
243-
'path': self.path,
244-
'environment': environment,
245-
'project': jedi.Project(path=project_path, sys_path=sys_path),
245+
#'path': self.path,
246+
#'environment': environment,
247+
#'project': jedi.Project(path=project_path, sys_path=sys_path),
248+
'namespaces': [__main__.__dict__],
246249
}
247250

248251
if position:
249252
# Deprecated by Jedi to use in Script() constructor
250253
kwargs += _utils.position_to_jedi_linecolumn(self, position)
251254

252-
return jedi.Script(**kwargs)
255+
return jedi.Interpreter(**kwargs)
253256

254257
def get_enviroment(self, environment_path=None):
255258
# TODO(gatesn): #339 - make better use of jedi environments, they seem pretty powerful

0 commit comments

Comments
 (0)