我试图使用flake8(pydocstyle)检查docstring的质量,并得到以下错误:
D205:摘要行和描述之间所需的1行空白行--这是我的代码看起来很像的示例:
def func(
self,
source: str,
) -> str:
"""
Generates an sql query for a temporary table by searching
the source code in the rules and restrictions table for these sources.
Args:
source: data source code
Returns:
sql query for creating a table
"""
sql = None
一条很难分开的长长的信息。最大行长= 100,如何正确地将句子转到另一行?还是更容易忽略这种情况下的错误?
我试着分裂,但意义有点失去了。到目前为止只有这样
# noqa D205 1 blank line required between summary line and description
发布于 2022-09-09 12:05:33
实际上,许多著名的包并不能通过flake8
,例如numpy
中的所有规则.别对自己太苛刻了。如果你真的想解决这个烦人的问题,这里有一些解决办法。
第一个解决方案:在"""
之后添加一个摘要注释,并在摘要和desc之间添加一个空格。
def func(
self,
source: str,
) -> str:
"""Generate a sql query
Generates an sql query for a temporary table by searching
the source code in the rules and restrictions table for these sources.
summary
Args:
source: data source code
Returns:
sql query for creating a table
"""
sql = None
第二种解决方案:通过编辑D205
强制忽略.flake8
https://stackoverflow.com/questions/73660570
复制相似问题