def parse_float(arg, name, parser):
    """
    Tries to parse a string as a float.

    :param arg:    The arg to parse as a float
    :param name:   A description of the argument used for error messages
    :param parser: The parser used to report an error message
    :return: The parsed float if succeeds or the original argument if fails
    """
    if arg == 'None' or arg is None:
        return None
    else:
        try:
            arg = float(arg)
            return arg
        except ValueError:
            parser.error("'" + arg + "' is not a valid " + name)
            return None
