|
3 | 3 | from __future__ import annotations
|
4 | 4 | import logging
|
5 | 5 | from typing import Any, Dict, List, TYPE_CHECKING
|
| 6 | + |
| 7 | +import jedi |
| 8 | + |
6 | 9 | from pylsp import hookimpl, uris, _utils
|
7 | 10 |
|
8 | 11 | if TYPE_CHECKING:
|
@@ -43,12 +46,19 @@ def pylsp_definitions(
|
43 | 46 | settings = config.plugin_settings("jedi_definition")
|
44 | 47 | code_position = _utils.position_to_jedi_linecolumn(document, position)
|
45 | 48 | script = document.jedi_script(use_document_path=True)
|
46 |
| - definitions = script.goto( |
47 |
| - follow_imports=settings.get("follow_imports", True), |
48 |
| - follow_builtin_imports=settings.get("follow_builtin_imports", True), |
49 |
| - **code_position, |
50 |
| - ) |
51 |
| - definitions = [_resolve_definition(d, script, settings) for d in definitions] |
| 49 | + auto_import_modules = jedi.settings.auto_import_modules |
| 50 | + |
| 51 | + try: |
| 52 | + jedi.settings.auto_import_modules = [] |
| 53 | + definitions = script.goto( |
| 54 | + follow_imports=settings.get("follow_imports", True), |
| 55 | + follow_builtin_imports=settings.get("follow_builtin_imports", True), |
| 56 | + **code_position, |
| 57 | + ) |
| 58 | + definitions = [_resolve_definition(d, script, settings) for d in definitions] |
| 59 | + finally: |
| 60 | + jedi.settings.auto_import_modules = auto_import_modules |
| 61 | + |
52 | 62 | follow_builtin_defns = settings.get("follow_builtin_definitions", True)
|
53 | 63 | return [
|
54 | 64 | {
|
|
0 commit comments