Coverage for src / lilbee / core / config / parsing.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-05-15 20:55 +0000

1"""Boolean parsing helpers used by :mod:`lilbee.config` validators.""" 

2 

3_BOOL_TRUE = frozenset({"true", "1", "yes"}) 

4_BOOL_FALSE = frozenset({"false", "0", "no"}) 

5 

6 

7def parse_bool(raw: str) -> bool: 

8 """Parse true/1/yes or false/0/no; raises ValueError on anything else.""" 

9 normalized = raw.strip().lower() 

10 if normalized in _BOOL_TRUE: 

11 return True 

12 if normalized in _BOOL_FALSE: 

13 return False 

14 raise ValueError(f"Invalid boolean: {raw!r}")