Skip to content

Commit ac79cef

Browse files
jackwickhamgatesn
authored andcommitted
Don't go to definition of builtin modules (#687)
1 parent 1ea46ae commit ac79cef

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

pyls/plugins/definition.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ def pyls_definitions(config, document, position):
2020
'end': {'line': d.line - 1, 'character': d.column + len(d.name)},
2121
}
2222
}
23-
for d in definitions
24-
if d.is_definition() and d.line is not None and d.column is not None and d.module_path is not None
23+
for d in definitions if d.is_definition() and _not_internal_definition(d)
2524
]
25+
26+
27+
def _not_internal_definition(definition):
28+
return (
29+
definition.line is not None and
30+
definition.column is not None and
31+
definition.module_path is not None and
32+
not definition.in_builtin_module()
33+
)

test/plugins/test_definitions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_builtin_definition(config):
4040

4141
# No go-to def for builtins
4242
doc = Document(DOC_URI, DOC)
43-
assert len(pyls_definitions(config, doc, cursor_pos)) == 1
43+
assert not pyls_definitions(config, doc, cursor_pos)
4444

4545

4646
def test_assignment(config):

0 commit comments

Comments
 (0)