Replaces deprecated (pre python 3.12) distutils strtobool function. True values are y, yes, t, true, on and 1; False values are n, no, f, false, off and 0. Raises ValueError if val is anything else.
(val: str)
| 79 | |
| 80 | |
| 81 | def _strtobool(val: str) -> bool: |
| 82 | """ |
| 83 | Replaces deprecated (pre python 3.12) |
| 84 | distutils strtobool function. |
| 85 | |
| 86 | True values are y, yes, t, true, on and 1; |
| 87 | False values are n, no, f, false, off and 0. |
| 88 | Raises ValueError if val is anything else. |
| 89 | """ |
| 90 | val = val.lower() |
| 91 | if val in ("y", "yes", "t", "true", "on", "1"): |
| 92 | return True |
| 93 | elif val in ("n", "no", "f", "false", "off", "0"): |
| 94 | return False |
| 95 | else: |
| 96 | raise ValueError(f"invalid truth value {val}") |
| 97 | |
| 98 | |
| 99 | _seed = None |
no outgoing calls
no test coverage detected
searching dependent graphs…