def foobar(filename, copy, dtype, iterable, shape, files):
"""
foobar is 42.
Parameters
----------
filename : str
copy : bool
dtype : data-type
iterable : iterable object
shape : int or tuple of int
files : list of str
Returns
-------
foobarfoo : int
"""
pass
是否可以检查文档字符串类型是否正确?
(附带问题:numpy 可以返回/打印它发现的函数签名吗?)
例如,我希望以下失败:
返回类型
def foobar():
"""
Returns
-------
blub : int
"""
return "foo"
或者
def foobar(a, b):
"""
Parameters
----------
a : number
b : number
Returns
-------
blub : int
"""
if a > b:
return "foo"
return 42
参数类型
def foobar(a, b):
"""
Parameters
----------
a : str
b : int
Returns
-------
blub : int
"""
return a * b