私はコードを持っていると仮定します
def foo():
bar = 1
wibble = 3
return locals()
私の現在の構文チェッカー(syntastic.vimを使用したflake8)は、両方の変数で「割り当てられていますが、使用されていません」というエラーをスローします。ただし、 locals() は、明示的ではないにしても、実際に使用されていることを意味します。
def foo():
bar = 1
wibble = 3 # <-- I still want this to throw as it is definitely not being used
return bar
locals() を認識して寛大になる Python チェッカーまたはカスタム設定はありますか?
編集:
これは、.vimrc の警告を抑制する vim/syntastic/flake8 の簡単で汚い解決策です。
"Ignore unused variable warnings whenever locals() is being used in a file
function! LocalsWarningSuppress()
if ( search("locals()",'nw') > 0)
let g:syntastic_python_checker='flake8 --ignore=W806'
else
let g:syntastic_python_checker='flake8'
endif
endfunction
au BufWritePre **/(filter_pattern)*py call LocalsWarningSuppress()