Exemplo n.º 1
0
def test_copy_docstrings__extend_args():
    def func():
        """Test function.

        Args:
            arg_0: 0th test arg

        Returns:
            None
        """

    expected_docstring = """
    Test function.

    Args:
        arg_0: 0th test arg
        arg_1: First test arg
        arg_2: Second test arg

    Returns:
        None
    """

    modified_func = copy_docstrings(func, [func_template])
    assert modified_func.__doc__.strip() == cleandoc(expected_docstring.strip())
Exemplo n.º 2
0
 def wrapper(func):
     try:
         func = copy_annotations(func, template_functions,
                                 include_return_annotation)
         func = copy_docstrings(func, template_functions, include_sections,
                                exclude_args)
         func = copy_signatures(func, template_functions, exclude_args)
     # If for any reason one of these steps fail, just log the error and return the original function
     except Exception:
         logger.exception(f'Failed to modify {func.__name__}')
     return func
Exemplo n.º 3
0
def test_copy_docstrings__without_returns():
    def func():
        """Test function."""

    expected_docstring = """
    Test function.

    Args:
        arg_1: First test arg
        arg_2: Second test arg
    """

    modified_func = copy_docstrings(func, [func_template])
    assert modified_func.__doc__.strip() == cleandoc(expected_docstring.strip())
Exemplo n.º 4
0
def document_common_args(func):
    """Just add common args to a function's docstring without modifying the signature"""
    template_functions = (_dry_run, _session)
    func = copy_annotations(func, template_functions)
    func = copy_docstrings(func, template_functions)
    return func