Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuration setting for Vim PEP-8 plugin to ignore errors and warnings?

Tags:

python

vim

pep8

I am using this plugin to detect PEP-8 errors and warnings in Vim: http://www.vim.org/scripts/script.php?script_id=3430

I want to ignore few errors and warnings like E501 & W601 given in the backend pep8 tool: http://pypi.python.org/pypi/pep8

When I looked at the plugin code, I can see it has support for this:

from pep8checker import Pep8Checker

args = vim.eval('string(g:pep8_args)')
select = vim.eval('string(g:pep8_select)')
ignore = vim.eval('string(g:pep8_ignore)')

if select:
    args = args + ' --select=%s' % select

if ignore:
    args = args + ' --ignore=%s' % ignore

pep8_checker = Pep8Checker(cmd, args)

But how do I use it ?

like image 587
baijum Avatar asked Mar 15 '12 05:03

baijum


4 Answers

For those folks that stumble across this question and the above answer doesn't work, here's some solutions for other Vim Python plugins:

For Syntastic:

let g:syntastic_python_checker="flake8"
let g:syntastic_python_checker_args="--ignore=E501,W601"

UPDATE: newer versions of Syntastic use this instead:

let g:syntastic_python_checkers=["flake8"]

For python-mode:

let g:pymode_lint_ignore="E501,W601"

Ensure that these are set before Pathogen or Vundle are triggered.

like image 152
robbrit Avatar answered Oct 17 '22 05:10

robbrit


You need to set the variable g:pep8_ignore; you should put this in your vimrc.

let g:pep8_ignore="E501,W601"
like image 24
Chris Morgan Avatar answered Oct 17 '22 05:10

Chris Morgan


After trying all of robbrit's solutions and finding that none of them worked for me, I read some of the documentation for Syntastic. To pass args to a checker, you need to know several things. The following is the command syntax:

let g:syntastic_python_checkers=["<checker_type>"]

let g:syntastic_<filetype>_<checker_name>_args="--ignore=E501,W601,..."

This means that if you use flake8, you would write:

let g:syntastic_python_checkers=["flake8"]
let g:syntastic_python_flake8_args="--ignore=E501,W601"

Hope this helps someone avoid spending ages trying to figure this out like I did.

like image 10
user3934630 Avatar answered Oct 17 '22 04:10

user3934630


If you use python-mode you need to use list now:

let g:pymode_lint_ignore=["E501", "W601"]
like image 1
hg8 Avatar answered Oct 17 '22 05:10

hg8