示例#1
0
def test_infer_descriptions_from_docstring_numpy():
    @solid
    def good_numpy(_context, hello: str, optional: int = 5):
        """
        Test

        Parameters
        ----------
        hello:
            hello world param
        optional:
            optional param, default 5
        """
        return hello + str(optional)

    defs = infer_input_props(good_numpy.compute_fn.decorated_fn,
                             context_arg_provided=True)
    assert len(defs) == 2

    hello_param = defs[0]
    assert hello_param.name == "hello"
    assert hello_param.annotation == str
    assert hello_param.description == "hello world param"

    optional_param = defs[1]
    assert optional_param.name == "optional"
    assert optional_param.annotation == int
    assert optional_param.default_value == 5
    assert optional_param.description == "optional param, default 5"
示例#2
0
def test_infer_descriptions_from_docstring_google():
    @solid
    def good_google(_context, hello: str, optional: int = 5):
        """
        Test

        Args:
            hello       (str): hello world param
            optional    (int, optional): optional param. Defaults to 5.
        """
        return hello + str(optional)

    defs = infer_input_props(good_google.compute_fn.decorated_fn,
                             context_arg_provided=True)
    assert len(defs) == 2

    hello_param = defs[0]
    assert hello_param.name == "hello"
    assert hello_param.annotation == str
    assert hello_param.description == "hello world param"

    optional_param = defs[1]
    assert optional_param.name == "optional"
    assert optional_param.annotation == int
    assert optional_param.default_value == 5
    assert optional_param.description == "optional param. Defaults to 5."
示例#3
0
def test_infer_input_description_from_docstring_rest():
    @solid
    def rest(_context, hello: str, optional: int = 5):
        """
        :param str hello: hello world param
        :param int optional: optional param, defaults to 5
        """
        return hello + str(optional)

    defs = infer_input_props(rest.compute_fn, context_arg_provided=True)
    assert len(defs) == 2

    hello_param = defs[0]
    assert hello_param.name == "hello"
    assert hello_param.annotation == str

    optional_param = defs[1]
    assert optional_param.name == "optional"
    assert optional_param.annotation == int
    assert optional_param.default_value == 5