def return_arg_type(at_position):
    """
    Wrap the return value with the result of `type(args[at_position])`
    """

    def decorator(to_wrap):
        @functools.wraps(to_wrap)
        def wrapper(*args, **kwargs):
            result = to_wrap(*args, **kwargs)
            ReturnType = type(args[at_position])
            return ReturnType(result)

        return wrapper

    return decorator
Wrap the return value with the result of `type(args[at_position])`