问题
According to Google's standard for Python:
http://google-styleguide.googlecode.com/svn/trunk/pyguide.html
Perhaps a group of tools that can cover most of the standard?
回答1:
pylint will do this kind of checking but you need a configuration file to make it look for things exactly as Google's style guide dictates.
Google publishes this pylink file as part of various projects.
https://www.chromium.org/chromium-os/python-style-guidelines#TOC-pylint
The rc file itself is here:
https://github.com/vinitkumar/googlecl/blob/master/googlecl-pylint.rc
Copy it to /path/to/pylintrc
and run pylint on your files:
pylint -E --rcfile=/path/to/pylintrc file.py file2.py
回答2:
You can find the pylint.rc files used by Google's projects on github, such as the following two:
https://github.com/google/apitools/blob/master/default.pylintrc(Link is dead)- https://github.com/google/seq2seq/blob/master/pylintrc
It seems that different projects could use differently customized pylint configuration files, although most of the configurations are the same.
You can further customize the pylintrc files based on these Google published pylint.rc files.
To get a complete pylint report with the score, use command:
pylint --rcfile=<path to google pylintrc> <your.py>
来源:https://stackoverflow.com/questions/29597618/is-there-a-tool-to-lint-python-based-on-the-google-style-guide