Python:如何使用 epytext 在 returning 多个值时记录 return 值?

Python: how to document the return value when returning multiple values, using epytext?

一个简单的函数:

def foo():
    a = 1
    b = 2
    return a, b

您将如何使用 epytext 样式记录(多个)return 值?

作为单个元组?

def foo():
    """
    This function
    @return (a, b): a tuple of a and b representing...
    """
    a = 1
    b = 2
    return a, b

或者每个变量有单独的 @return 标签? (甚至"legal"?)

def foo():
    """
    This function
    @return a: a int representing...
    @return b: a int representing...
    """
    a = 1
    b = 2
    return a, b

在Python中,元组文字是由逗号创建的,而不是括号(空元组文字()除外,这是一种特殊情况),所以return a, b 首先创建一个 tuple 然后 returns 它。 IOW,你不是 "returning multiple values" 而是一个 tuple 对象,所以答案很明显。