MypyBear.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:coala-bears 作者: coala 项目源码 文件源码
def add_param_docs(param_map):
    """
    Append documentation from FLAG_MAP to a function's docstring.

    :param param_map:
        A mapping of argument names (strings) to FlagInfo objects.
    :return:
        A decorator that appends flag information to a function's docstring.
    """
    def decorator(func):
        func.__doc__ = textwrap.dedent(func.__doc__) + '\n'.join(
            ':param {}:\n{}'.format(name, textwrap.indent(arg.doc, '    '))
            for name, arg in param_map.items())
        return func
    return decorator


# Mypy generates messages in the format:
#    blabla.py: note: In function "f":
#    blabla.py:2: error: Unsupported operand types for ...
# The "note" messages are only adding info coala should already know,
# so discard those. We're only capturing the errors.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号