{"record":{"id":"40cb34ff356ba8bb","repo":"pola-rs/polars","slug":"time-unit-must-be-one-of-ms-us-ns-g","errorCode":null,"errorMessage":"`time_unit` must be one of {{'ms', 'us', 'ns'}}, got {time_unit!r}","messagePattern":"`time_unit` must be one of (.+?)\\}, got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/_utils/convert.py","lineNumber":224,"sourceCode":"        _raise_invalid_time_unit(time_unit)\n\n\ndef to_py_decimal(prec: int, value: str) -> Decimal:\n    \"\"\"Convert decimal components to a Python Decimal object.\"\"\"\n    return _create_decimal_with_prec(prec)(value)\n\n\n@lru_cache(None)\ndef _create_decimal_with_prec(\n    precision: int,\n) -> Callable[[str], Decimal]:\n    # pre-cache contexts so we don't have to spend time on recreating them every time\n    return Context(prec=precision).create_decimal\n\n\ndef _raise_invalid_time_unit(time_unit: Any) -> NoReturn:\n    msg = f\"`time_unit` must be one of {{'ms', 'us', 'ns'}}, got {time_unit!r}\"\n    raise ValueError(msg)\n","sourceCodeStart":206,"sourceCodeEnd":225,"githubUrl":"https://github.com/pola-rs/polars/blob/9b5d73fd00236295624374b075d16b1fe6ec6df9/py-polars/src/polars/_utils/convert.py#L206-L225","documentation":"ValueError raised by _raise_invalid_time_unit: a temporal conversion received a time_unit outside the supported set 'ms'/'us'/'ns'. It is a shared validation helper used by datetime/timedelta conversion entry points; the message names the rejected time_unit value.","triggerScenarios":"Invalid time_unit argument.","commonSituations":"See trigger scenarios.","solutions":["Use time_unit 'ms', 'us', or 'ns'."],"exampleFix":"pl.datetime(..., time_unit='us')","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9b5d73fd00236295624374b075d16b1fe6ec6df9","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}