如何记录参数是 python 中的函数类型

How to document a parameter is a function type in python

def method(*, var_param, function_param):
    """Call 'function_param' with 'var_param'

    :param var_param: the value to pass to the function_param
    :type log: str
    :param function_param: the method to call with var_param
    :type function_param: ?????
    :return: Nothing
    :rtype: None
    """
    function_param(var_param)

我正在使用 pycharm 2017.1.1 进行编码,我想知道我需要在 :type function_param: 中输入什么来指示参数是 'function'?

== 编辑 ==

我尝试使用 function,但 pycharm 抱怨:

您可以使用 "callable" 类型。

def method(*, var_param, function_param):
    """Call 'function_param' with 'var_param'

    :param var_param: the value to pass to the function_param
    :type log: str
    :param function_param: the method to call with var_param
    :type function_param: callable[str]
    :return: Nothing
    :rtype: None
    """
    function_param(var_param)

因为你的参数是一个str,你可以在函数签名中设置它。

更多信息: