[英]Is there a tool to lint Python based on the Google style guide?
pylint會進行這種檢查,但是你需要一個配置文件來讓它完全按照谷歌風格指南的要求來查找。
Google將此pylink文件作為各種項目的一部分發布。
https://www.chromium.org/chromium-os/python-style-guidelines#TOC-pylint
rc文件本身在這里:
https://github.com/vinitkumar/googlecl/blob/master/googlecl-pylint.rc
將其復制到/path/to/pylintrc
並在文件上運行pylint:
pylint -E --rcfile=/path/to/pylintrc file.py file2.py
您可以在github上找到Google項目使用的pylint.rc文件,例如以下兩個:
雖然大多數配置都是相同的,但似乎不同的項目可以使用不同的自定義pylint配置文件。
您可以根據這些Google發布的pylint.rc文件進一步自定義pylintrc文件。
要使用分數獲得完整的pylint報告,請使用命令:
pylint --rcfile=<path to google pylintrc> <your.py>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.