def __init__(self, test):
if not callable(test):
raise ValueError("Relguard test has to be callable")
# extract simplified signature
test_args = _getparams(test)
# varying args are not allowed, they make no sense in reguards.
_kinds = {x[1] for x in test_args}
if (p_kind.POSITIONAL_ONLY in _kinds or
p_kind.VAR_POSITIONAL in _kinds or
p_kind.VAR_KEYWORD in _kinds):
raise ValueError("Relguard test must take only named not varying arguments")
self.test = test
self.__argnames__ = {x[0] for x in test_args}
function_pattern_matching.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录