Skip to content

Commit 4398552

Browse files
author
Gerard Vermeulen
committed
PR: improves how jedi handles numpy
1 parent ff41880 commit 4398552

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

pylsp/config/schema.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@
8787
"uniqueItems": true,
8888
"description": "List of errors and warnings to enable."
8989
},
90+
"pylsp.plugins.jedi.auto_import_modules": {
91+
"type": "array",
92+
"default": ["numpy", "gi"],
93+
"items": {
94+
"type": "string"
95+
},
96+
"description": "List of module names for jedi.settings.auto_import_modules."
97+
},
9098
"pylsp.plugins.jedi.extra_paths": {
9199
"type": "array",
92100
"default": [],

pylsp/workspace.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
log = logging.getLogger(__name__)
1616

17+
DEFAULT_AUTO_IMPORT_MODULES = ["numpy", "gi"]
18+
1719
# TODO: this is not the best e.g. we capture numbers
1820
RE_START_WORD = re.compile('[A-Za-z_0-9]*$')
1921
RE_END_WORD = re.compile('^[A-Za-z_0-9]*')
@@ -252,6 +254,8 @@ def jedi_script(self, position=None, use_document_path=False):
252254

253255
if self._config:
254256
jedi_settings = self._config.plugin_settings('jedi', document_path=self.path)
257+
jedi.settings.auto_import_modules = jedi_settings.get('auto_import_modules',
258+
DEFAULT_AUTO_IMPORT_MODULES)
255259
environment_path = jedi_settings.get('environment')
256260
extra_paths = jedi_settings.get('extra_paths') or []
257261
env_vars = jedi_settings.get('env_vars')

0 commit comments

Comments
 (0)