diff --git a/pylsp/plugins/definition.py b/pylsp/plugins/definition.py index d20d8db0..53eda915 100644 --- a/pylsp/plugins/definition.py +++ b/pylsp/plugins/definition.py @@ -47,6 +47,7 @@ def pylsp_definitions( code_position = _utils.position_to_jedi_linecolumn(document, position) script = document.jedi_script(use_document_path=True) auto_import_modules = jedi.settings.auto_import_modules + try: jedi.settings.auto_import_modules = [] definitions = script.goto( @@ -57,6 +58,7 @@ def pylsp_definitions( definitions = [_resolve_definition(d, script, settings) for d in definitions] finally: jedi.settings.auto_import_modules = auto_import_modules + follow_builtin_defns = settings.get("follow_builtin_definitions", True) return [ { diff --git a/test/plugins/test_definitions.py b/test/plugins/test_definitions.py index 45835c8c..c366e8ca 100644 --- a/test/plugins/test_definitions.py +++ b/test/plugins/test_definitions.py @@ -42,14 +42,6 @@ def my_func(): """ -def test_numpy(config, workspace): - cursor_pos = {"line": 29, "character": 8} - - doc = Document(DOC_URI, workspace, DOC) - defns = pylsp_definitions(config, doc, cursor_pos) - assert len(defns) > 0, defns - - def test_definitions(config, workspace): # Over 'a' in print a cursor_pos = {"line": 3, "character": 6} @@ -100,6 +92,15 @@ def test_definition_with_multihop_inference_goto(config, workspace): ) +def test_numpy_definition(config, workspace): + # Over numpy.ones + cursor_pos = {"line": 29, "character": 8} + + doc = Document(DOC_URI, workspace, DOC) + defns = pylsp_definitions(config, doc, cursor_pos) + assert len(defns) > 0, defns + + def test_builtin_definition(config, workspace): # Over 'i' in dict cursor_pos = {"line": 8, "character": 24}