Skip to content

Commit

Permalink
Add code in front of the diagnostic message for flake8 (#885)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhao committed Nov 7, 2020
1 parent cf59b8f commit 7a98c2c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pyls/plugins/flake8_lint.py
Expand Up @@ -144,6 +144,8 @@ def parse_stdout(document, stdout):
_, line, character, code, msg = parsed_line
line = int(line) - 1
character = int(character) - 1
# show also the code in message
msg = code + ' ' + msg
diagnostics.append(
{
'source': 'flake8',
Expand Down
4 changes: 2 additions & 2 deletions test/plugins/test_flake8_lint.py
Expand Up @@ -31,7 +31,7 @@ def temp_document(doc_text, workspace):
def test_flake8_unsaved(workspace):
doc = Document('', workspace, DOC)
diags = flake8_lint.pyls_lint(workspace, doc)
msg = 'local variable \'a\' is assigned to but never used'
msg = 'F841 local variable \'a\' is assigned to but never used'
unused_var = [d for d in diags if d['message'] == msg][0]

assert unused_var['source'] == 'flake8'
Expand All @@ -45,7 +45,7 @@ def test_flake8_lint(workspace):
try:
name, doc = temp_document(DOC, workspace)
diags = flake8_lint.pyls_lint(workspace, doc)
msg = 'local variable \'a\' is assigned to but never used'
msg = 'F841 local variable \'a\' is assigned to but never used'
unused_var = [d for d in diags if d['message'] == msg][0]

assert unused_var['source'] == 'flake8'
Expand Down

0 comments on commit 7a98c2c

Please sign in to comment.