繁体   English   中英

如何解决 flake8 错误“D205:摘要行和描述之间需要 1 个空白行”?

[英]How can I resolve flake8 error "D205: 1 blank line required between summary line and description"?

我正在尝试使用 flake8(pydocstyle) 检查我的文档字符串的质量,我收到了这个错误:

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

很难分开的长消息。 而 max line length = 100 如何正确地将句子转移到另一行? 还是在这种情况下更容易忽略错误?

我试图划分,但意思有点失落。 到目前为止只有这样

# noqa D205 1 blank line required between summary line and description

实际上,很多知名的包都没有通过numpy flake8 不要对自己那么苛刻。 如果你真的想解决这个烦人的问题,这里有一些解决方案。

第一种解决方案:在"""之后添加一个摘要注释,并在summary和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

第二种解决方案:通过编辑.flake8强制忽略D205

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM