Return a boolean value translating from other types if necessary.
(value: Any | None)
| 595 | |
| 596 | |
| 597 | def convert_to_boolean(value: Any | None) -> bool: |
| 598 | """Return a boolean value translating from other types if necessary.""" |
| 599 | if isinstance(value, bool): |
| 600 | return value |
| 601 | if not isinstance(value, str): |
| 602 | value = str(value) |
| 603 | if value.lower() not in configparser.RawConfigParser.BOOLEAN_STATES: |
| 604 | raise ValueError(f"Not a boolean: {value}") |
| 605 | return configparser.RawConfigParser.BOOLEAN_STATES[value.lower()] |
| 606 | |
| 607 | |
| 608 | def split_directive(s: str) -> tuple[list[str], list[str]]: |
no test coverage detected
searching dependent graphs…