Pylint代码审查:Wildcard import XXX
如果函数名重名,或者要导入的内容里面包含了from datetime import datetime,
而在你的文件里 import datetime,如果import * 是在这之后,它会覆盖import datetime
Pylint代码审查:Missing docstring
"""Doc string.
bababababa.
"""
Pylint代码审查:Invalid name "xx" (should match [a-z_][a-z0-9_]{2,30}$)
变量名太短,长度应至少为3,且首字母应以a-z和_开头。
常量全部大写:MY_CONST
变量名、函数、方法名以小写字母开头,中间可以用下划线分隔 some_xx_xx
类名应以大写字母开头 MyClassName
类的私有变量、方法命 __some_xx
Pylint代码审查:Too many branches (20/12)
if else太多,拆分函数吧
Pylint代码审查:Line too long (xx/80)
1. import的东东太多
from your.utils import some, another, some_x, another_x, \
some_y, another_y
2. 条件太多
if some or another or another_x and another_y and some_z \
or another_y
3. 字符串太长
some_var = "blablablablablabla,mojimojimojimojimojimoji %s" % \
another_var
或者
some_var = ("blablablablablablablablablablabla"
"mojimojimojimojimojimojimoji")
或者
some_var = """blablablablablabla,mojimojimojimojimojimoji
注意这里要顶格到最前面,否则会有多余的空白字符
"""
4. 函数括号里的东东太多,参数最好不要超过5个
some_var = some_func(some_x, some_y,
another_x, another_y)
或者
some_var = some_func(
some_x, some_y,
another_x, another_y)
或者
some_var = some_func(
some_x, some_y,
another_x, another_y)
5. 列表内容比较多噻
some_list = [
some_x, some_y,
another_x, anoter_y
]
some_list = [expression for x in a_list
if some_very_very_long_expr]
6. 字典内容比较多噻
some_dict = {
"some_x": some_x,
"some_y": some_y
}
7. 三元运算表达式太长
some_var = (some_value
if very_very_very_long_expression
else another_value)
8. 一行中的“.”操作表达式很多
some_var = (some_var.replace('xx', 'yy')
.replace('zz', 'mm')
.split('|'))
Windows -> Prefereces -> General -> Editors -> Text Editors
勾选上 Show print margin
Pylint代码审查:Comma not followed by a space
在一行的代码,逗号后面加个空格吧;