[Python] Pylint 程式碼優化
1. VS Code中Extension安裝ms-python.python
2. 回到程式碼頁面 ctrl+shift+P 啟動
Python: Enable/Disable Linting
選擇:Enable
Python: Select Linter
選擇:pylint
.vscode/setting.json 內容會變成:
“python.pythonPath”: “/usr/local/bin/python3”,
“python.linting.enabled”: true,
“python.linting.pylintEnabled”: true,
“python.linting.pylintArgs”: [
“ — disable=C,R”,
“ — errors-only”,
“disable=no-else-return”
]
其中,python.linting.pylintArgs:放置一些要排除的檢查
3. 最後在terminal中在要檢查的資料夾中執行
pylint XXXXXX.py
結果:
(license) ezra@ezra-HP-Pavilion-Gaming-Laptop-17-cd1xxx:~/文件/GitHub/RegisterCode$ pylint rsa_customer.py
************* Module rsa_customer
rsa_customer.py:30:12: R1705: Unnecessary “else” after “return” (no-else-return)
rsa_customer.py:55:16: E1102: verifier.verify is not callable (not-callable)
rsa_customer.py:56:4: R1705: Unnecessary “else” after “return” (no-else-return)
rsa_customer.py:78:8: R1705: Unnecessary “else” after “return” (no-else-return)— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
Your code has been rated at 9.13/10 (previous run: 9.13/10, +0.00)