我应该如何在文档字符串中对类似的异常进行分组?

时间:2015-05-14 05:51:13

标签: python docstring

我没有在任何风格指南中看到它。我应该组合类似的异常类型还是将它们分成不同的行:

"""
This is a Google style docs.
...
...
Raises:
    TypeError: foo() missing 1 required positional argument. Key must be a numeric value.
    KeyError: bar
"""

或者这个:

"""
This is a Google style docs.
...
...
Raises:
    TypeError: foo() missing 1 required positional argument
    TypeError: key must be a numeric value
    KeyError: bar
"""

1 个答案:

答案 0 :(得分:0)

我认为第二步。

"""
This is a Google style docs.
...
...
Raises:
    TypeError: 1. foo() missing 1 required positional argument.
               2. key must be a numeric value.
               3. ...
    KeyError:  1. bar key is missing.
               2. ...
"""