Skip to content

Commit 71b8385

Browse files
committed
get diagnostics from pyls_lint
1 parent 2d12e54 commit 71b8385

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

pyls/plugins/importmagic_lint.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def pyls_lint(document):
125125

126126

127127
@hookimpl
128-
def pyls_code_actions(config, document, context):
128+
def pyls_code_actions(config, document):
129129
"""Build a list of actions to be suggested to the user. Each action follow this format:
130130
{
131131
'title': 'importmagic',
@@ -150,11 +150,9 @@ def pyls_code_actions(config, document, context):
150150
# TODO (youben): add project path for indexing
151151
index = _get_index(sys.path)
152152
actions = []
153-
diagnostics = context.get('diagnostics', [])
154-
for diagnostic in diagnostics:
155-
if diagnostic.get('source') != SOURCE:
156-
continue
157153

154+
diagnostics = pyls_lint(document)
155+
for diagnostic in diagnostics:
158156
message = diagnostic.get('message', '')
159157
unref_match = UNREF_RE.match(message)
160158
unres_match = UNRES_RE.match(message)

test/plugins/test_importmagic_lint.py

+1-16
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,9 @@ def test_importmagic_lint():
3838

3939

4040
def test_importmagic_actions(config):
41-
context = {
42-
'diagnostics': [
43-
{
44-
'range':
45-
{
46-
'start': {'line': 1, 'character': 0},
47-
'end': {'line': 1, 'character': 10}
48-
},
49-
'message': "Unresolved import 'time.sleep'",
50-
'severity': lsp.DiagnosticSeverity.Hint,
51-
'source': importmagic_lint.SOURCE
52-
}
53-
]
54-
}
55-
5641
try:
5742
name, doc = temp_document(DOC)
58-
actions = importmagic_lint.pyls_code_actions(config, doc, context)
43+
actions = importmagic_lint.pyls_code_actions(config, doc)
5944
action = [a for a in actions if a['title'] == 'Import "time"'][0]
6045
arguments = action['arguments'][0]
6146

0 commit comments

Comments
 (0)