{"record":{"id":"60342bc031f2ebf3","repo":"huggingface/transformers","slug":"truthy-value-expected-got-v-but-expected-one-of","errorCode":null,"errorMessage":"Truthy value expected: got {v} but expected one of yes/no, true/false, t/f, y/n, 1/0 (case insensitive).","messagePattern":"Truthy value expected: got (.+?) but expected one of yes/no, true/false, t/f, y/n, 1/0 \\(case insensitive\\)\\.","errorType":"exception","errorClass":"ArgumentTypeError","httpStatus":null,"severity":"error","filePath":"src/transformers/hf_argparser.py","lineNumber":44,"sourceCode":"from typing import Any, Literal, NewType, Union, get_type_hints\n\nimport yaml\n\n\nDataClass = NewType(\"DataClass\", Any)\nDataClassType = NewType(\"DataClassType\", Any)\n\n\n# From https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse\ndef string_to_bool(v):\n    if isinstance(v, bool):\n        return v\n    if v.lower() in (\"yes\", \"true\", \"t\", \"y\", \"1\"):\n        return True\n    elif v.lower() in (\"no\", \"false\", \"f\", \"n\", \"0\"):\n        return False\n    else:\n        raise ArgumentTypeError(\n            f\"Truthy value expected: got {v} but expected one of yes/no, true/false, t/f, y/n, 1/0 (case insensitive).\"\n        )\n\n\ndef make_choice_type_function(choices: list) -> Callable[[str], Any]:\n    \"\"\"\n    Creates a mapping function from each choices string representation to the actual value. Used to support multiple\n    value types for a single argument.\n\n    Args:\n        choices (list): List of choices.\n\n    Returns:\n        Callable[[str], Any]: Mapping function from string representation to actual value for each choice.\n    \"\"\"\n    str_to_choice = {str(choice): choice for choice in choices}\n    return lambda arg: str_to_choice.get(arg, arg)\n","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/hf_argparser.py#L26-L62","documentation":"Error \"Truthy value expected: got {v} but expected one of yes/no, true/false, t/f, y/n, 1/0 (case insensitive).\" thrown in huggingface/transformers.","triggerScenarios":"Raised in HfArgumentParser string_to_bool conversion when a CLI string is not one of yes/no/true/false/t/f/y/n/1/0.","commonSituations":"Passing an arbitrary string for a boolean dataclass field on the command line, e.g. --do_train maybe.","solutions":["Pass a boolean or one of yes/no, true/false, t/f, y/n, 1/0 for this argument.","Quote or correct the CLI value so it parses as a truthy string."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}