From 7a98c2c5f9de193a02c2a53405fb951ff7b3ae6b Mon Sep 17 00:00:00 2001 From: jdhao Date: Sun, 8 Nov 2020 00:05:46 +0800 Subject: [PATCH] Add code in front of the diagnostic message for flake8 (#885) --- pyls/plugins/flake8_lint.py | 2 ++ test/plugins/test_flake8_lint.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pyls/plugins/flake8_lint.py b/pyls/plugins/flake8_lint.py index 1a658518..4f2e054e 100644 --- a/pyls/plugins/flake8_lint.py +++ b/pyls/plugins/flake8_lint.py @@ -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', diff --git a/test/plugins/test_flake8_lint.py b/test/plugins/test_flake8_lint.py index acc770b2..75adf4ea 100644 --- a/test/plugins/test_flake8_lint.py +++ b/test/plugins/test_flake8_lint.py @@ -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' @@ -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'