Pylint为每个没有docstring的函数和方法(除了__init__
)报告一个错误。
这通常是需要的,所以我不想全局禁用它(在pylintrc
中,或在文件级别)。
然而,在我看来,有些情况下docstring是不必要的,甚至是有害的。例如:
def get_foo(self, foo_id):
"""Gets foo by its id.""""
return foos[foo_id]
这个方法是一个简单的getter,完全由它的签名描述。必须编写docstring是有害的,因为如果更改方法,它会创建重复的维护。
我希望能够设置(例如在pylintrc
)类似docstring_threshold=3
的内容,以在函数或方法短于3行代码时抑制缺少的docstring错误。有办法吗?
例如,使用pylint 1.3.1向pylintrc
docstring-min-length=10
添加一行。它在生成的pylintrc
pylint --generate-rcfile
文件中描述为Documentation reference。
相关问题 更多 >
编程相关推荐