from typing import Union


def _convert_to_kwargs(args: str) -> Union[dict, None]:
    """
    converts string of key=val, ..., key=val to dictionary

    Args:
        args: to convert

    Returns:
        dictionary of key values
    """
    parts = args.split(',')
    kwargs = {}
    for part in parts:
        keyval = part.split('=')
        if len(keyval) != 2:
            return None
        kwargs[keyval[0].strip()] = float(keyval[1].strip())
    return kwargs