def string_to_dict(var_string, allow_kv=True):
    # try:
    #     # Accept all valid "key":value types of json
    #     return_dict = json.loads(var_string)
    #     assert type(return_dict) is dict
    # except (TypeError, AttributeError, ValueError, AssertionError):
    try:
        # Accept all JSON and YAML
        return_dict = yaml.load(var_string)
        assert type(return_dict) is dict
    except (AttributeError, yaml.YAMLError, AssertionError):
        # if these fail, parse by key=value syntax
        try:
            assert allow_kv
            return_dict = parse_kv(var_string)
        except:
            raise exc.TowerCLIError(
                'failed to parse some of the extra '
                'variables.\nvariables: \n%s' % var_string
            )
    return return_dict
(str) -> int
dataset/ETHPy150Open ansible/tower-cli/lib/tower_cli/utils/parser.py/string_to_dict--crossover with--dataset/ETHPy150Open rohithpr/py-web-search/pws/google.py/try_cast_int