nvie / vim-flake8

Flake8 plugin for Vim
BSD 2-Clause "Simplified" License
1.07k stars 99 forks source link

Flake8 ignoring -ignore flag setting #60

Open Integralist opened 8 years ago

Integralist commented 8 years ago

Hello,

Problem

I call Flake8 whenever I write to a Buffer:

autocmd BufWritePost *.py :call Flake8()

But it shows a list of errors which I've already configured to be ignored:

foo.py|28 col 80| E501 line too long (88 > 79 characters)
foo.py|36 col 1| E302 expected 2 blank lines, found 1

Here are the relevant lines from my vimrc:

execute pathogen#infect()
filetype plugin indent on

set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_python_checkers = ['flake8', 'pylint']

let g:syntastic_python_pylint_args="-d C0103,C0111,R0201"
let g:syntastic_python_flake8_args='--ignore=F821,E302,E501'

Software

I'm using terminal NeoVim (NVIM 0.1.5-dev) on latest Mac OS X release (10.11.5)

Note: I have the same issue with standard OS X install of terminal Vim (7.3)

Notes

The Flake8 plugin appears to work as I can see it's being loaded as part of Syntastic:

Syntastic version: 3.7.0-157 (Vim 704, Darwin)                                                                    
Info for filetype: python                                                                                         
Global mode: active                                                                                               
Filetype python is active                                                                                         
The current file will be checked automatically                                                                    
Available checkers: flake8 pep8 pycodestyle pyflakes pylint python                                                
Currently enabled checkers: flake8 pylint

I've looked at :scriptnames and I can see the flake8 plugin is being loaded:

~/.vim/bundle/vim-flake8/ftplugin/python_flake8.vim
~/.vim/bundle/syntastic/syntax_checkers/python/flake8.vim

If I was to remove the following line from my vimrc:

let g:syntastic_python_flake8_args='--ignore=F821,E302,E501'

...then close Vim and re-open the relevant python file in Vim, I would see those errors appear in a quickfix window and that would be expected behaviour.

If I then put back that line into my vimrc, close Vim and re-open the relevant python file in Vim I'll see the errors are ignored. Again, expected behaviour.

The problem occurs only when calling Flake8 when writing to the current buffer. The errors re-appear, when they should be ignored.

Interestingly I noticed, when removing the flake8_args setting, that after opening the file and the quicklist window immediately appeared, that if I then wrote to the buffer I would get another quickfix window with the same errors. But the first quickfix window shows the command used as:

:flake8 "foo.py"

I think the problem is that when I use call Flake8 that I'm using the shell directly, maybe? This would explain why it's side-stepping my Syntastic ignore flag setting

ardentTech commented 8 years ago

@Integralist Did you ever get this sorted out? The Vim-Flake8 changelog for 1.6 indicates that Vim Flake8 configuration has been deprecated in favor of config files. The [Flake8] (http://flake8.pycqa.org/en/latest/user/configuration.html#user-configuration) documentation provides instructions on how to set up a config file, and then you can simply add the lines

[flake8]
ignore = F821,E302,E501

to it and reload Vim to see the changes take effect.

Integralist commented 8 years ago

@ardentTech have a look at my vimrc in my dotfile repo. It all works fine now after some required changes

ardentTech commented 8 years ago

@Integralist cool cool. My config file syntax was off, so I edited my comment above to correct that.