From b01520f6a3f196e0fee9ac859fc386aea6383fe4 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Mon, 2 Apr 2018 16:44:57 +0300 Subject: [PATCH] Checker python/flake8: allow multi-letter error codes. --- plugin/syntastic.vim | 2 +- syntax_checkers/python/flake8.vim | 28 ++++++++++++---------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim index 2c4a3f74..be338025 100644 --- a/plugin/syntastic.vim +++ b/plugin/syntastic.vim @@ -19,7 +19,7 @@ if has('reltime') lockvar! g:_SYNTASTIC_START endif -let g:_SYNTASTIC_VERSION = '3.8.0-108' +let g:_SYNTASTIC_VERSION = '3.8.0-109' lockvar g:_SYNTASTIC_VERSION " Sanity checks {{{1 diff --git a/syntax_checkers/python/flake8.vim b/syntax_checkers/python/flake8.vim index fb9f3ad2..cd651890 100644 --- a/syntax_checkers/python/flake8.vim +++ b/syntax_checkers/python/flake8.vim @@ -23,10 +23,8 @@ function! SyntaxCheckers_python_flake8_GetLocList() dict let errorformat = \ '%E%f:%l: could not compile,%-Z%p^,' . - \ '%A%f:%l:%c: %t%n: %m,' . - \ '%A%f:%l:%c: %t%n %m,' . - \ '%A%f:%l: %t%n: %m,' . - \ '%A%f:%l: %t%n %m,' . + \ '%A%f:%l:%c: %m,' . + \ '%A%f:%l: %m,' . \ '%-G%.%#' let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } @@ -37,23 +35,21 @@ function! SyntaxCheckers_python_flake8_GetLocList() dict \ 'env': env }) for e in loclist - " E*** and W*** are pep8 errors - " F*** are PyFlakes codes - " C*** are McCabe complexity messages - " N*** are naming conventions from pep8-naming - " H*** are OpenStack messages + " flake8 codes: https://gitlab.com/pycqa/flake8/issues/339 - if has_key(e, 'nr') - let e['text'] .= printf(' [%s%03d]', e['type'], e['nr']) - " E901 are syntax errors - " E902 are I/O errors - if e['type'] ==? 'E' && e['nr'] !~# '\m^9' + let parts = matchlist(e['text'], '\v\C^([A-Z]+)(\d+):?\s+(.*)') + if len(parts) >= 4 + let e['type'] = parts[1][0] + let e['text'] = printf('%s [%s%03d]', parts[3], parts[1], parts[2]) + + if e['type'] ==? 'E' && parts[2] !~# '\m^9' let e['subtype'] = 'Style' endif - call remove(e, 'nr') + else + let e['type'] = 'E' endif - if e['type'] =~? '\m^[CHNW]' + if e['type'] =~? '\m^[CHIMNRTW]' let e['subtype'] = 'Style' endif