Python语言规范之Pylint的使用
1、Pylint是什么
pip3 install pylint
$ which pylint /Library/Frameworks/Python.framework/Versions/3.9/bin/pylint
************* Module 704 leetcode/704.py:28:0: C0305: Trailing newlines (trailing-newlines) #文尾有多余的行 leetcode/704.py:1:0: C0114: Missing module docstring (missing-module-docstring) # 脚本首行没有添加注释 leetcode/704.py:4:11: W0621: Redefining name 'nums' from outer scope (line 23) (redefined-outer-name) #变量名字与函数参数名字不能一样 leetcode/704.py:4:28: W0621: Redefining name 'target' from outer scope (line 24) (redefined-outer-name) #变量名字与函数参数名字不能一样 leetcode/704.py:4:0: C0116: Missing function or method docstring (missing-function-docstring) #函数缺少注释,注释要放在函数的第一行而不是def的上面
Output:Using the default text output, the message format is :MESSAGE_TYPE: LINE_NUM:[OBJECT:] MESSAGEThere are 5 kind of message types :
* (C) convention, for programming standard violation
* (R) refactor, for bad code smell
* (W) warning, for python specific problems
* (E) error, for probable bugs in the code
* (F) fatal, if an error occurred which prevented pylint from doing further processing.
pylint --list-msgs
2)官网