I am using pydocstyle and I wonder why it raises the error D407 / Missing dashed underline after section ('Example')
against my code.
我使用的是pydocstyle,我想知道为什么它会在代码中出现错误D407/Missing下划线(‘Example’)。
My code looks like this:
我的代码如下所示:
def foo():
"""
Function description here...
Example:
Some example here...
"""
# some code here
I had similar problem in the past when I tried to add Note:
section. I wonder whether it is False-Positive error as I am using reStructuredText and I know that pydocstyle sometimes has problems to distinguish reST with Google and numpy styling. Please correct me if I am wrong, but isn't reST related to section pep257
described under Default conventions so I could literally turn off all these checks: D203, D212, D213, ..., D407, ...?
我在过去尝试添加备注:部分时也遇到过类似的问题。我想知道这是否是误报错误,因为我使用的是reStrutiredText,而且我知道pydocstyle有时在区分REST与Google和NumPy Style方面存在问题。如果我错了,请纠正我,但REST不是与默认约定中描述的PEP257部分相关吗,这样我就可以关闭所有这些检查:D203、D212、D213、...、D407、...?
更多回答
@Tomerikoo thanks for the edit. It looks better now :)
@Tmerikoo感谢您的编辑。现在看起来好多了:)
优秀答案推荐
It appears that my hunch was right and D407 is one of errors that is not related to reStructuredText.
看起来我的预感是正确的,D407是与reStrufredText无关的错误之一。
Note:
(same with Example:
) section is unused in reStructuredText as ..note::
shall be used instead.
注意:(与Example:相同)部分在reStructuredText中未使用,因为..注:应改为。
It's means that you need to include a line with -------
after Example:
as it shown here https://beta.ruff.rs/docs/rules/dashed-underline-after-section/
这意味着您需要在示例后添加一行-如此处所示https://beta.ruff.rs/docs/rules/dashed-underline-after-section/
In your case:
在您的案例中:
def foo():
"""
Function description here...
Example
-------
Some example here...
"""
# some code here
更多回答
我是一名优秀的程序员,十分优秀!