Just making function and command. Auto run by autocmd when save.
" .py delete whitespace when save
function! DeleteWhitespace()
try
%s#\s\{1,}$## " W293
%s#\($\n\s*\)\+\%$## " W291, W393
catch
endtry
endfunction
command! DeleteTrail call DeleteWhitespace()
autocmd BufWritePost *.py call DeleteWhitespace()
" .py auto vim-flake8 when save
autocmd BufWritePost *.py call Flake8()