Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
smacke committed Oct 1, 2023
1 parent de4442e commit 06193d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions pylsp/plugins/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 [
{
Expand Down
17 changes: 9 additions & 8 deletions test/plugins/test_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit 06193d0

Please sign in to comment.