Skip to content

Integrate code linting to your workflow

Swati Jaiswal edited this page Aug 28, 2019 · 1 revision

Install pylint

pip install pylint

Manually testing:

Run a pylint test after you have finished writing code before commiting

pylint <project_dir_name>

e.g. pylint scraper

Fix error if are reported by pylint and push the code.

Integrating with your editor (vim).

Add the following block of code in your .vimrc.

set errorformat=%f:%l:\ %m
autocmd FileType python setlocal makeprg=pylint\ --reports=n\ --msg-template=\"{path}:{line}:\ {msg_id}\ {symbol},\ {obj}\ {msg}\"\ %:p
autocmd BufWritePost *.py silent! make | redraw! 
autocmd QuickFixCmdPost [^l]* cwindow

Now pylint will automatically run everytime you save the file in vim with :w and you will see the pylint output in a vertically split window just below your code.