Coverage for lintro / enums / tools_value.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-04-03 18:53 +0000

1"""Tools value enum definitions. 

2 

3This module defines special values for tool selection. 

4""" 

5 

6from __future__ import annotations 

7 

8from enum import StrEnum, auto 

9 

10 

11class ToolsValue(StrEnum): 

12 """Special values for tool selection. 

13 

14 Values are lower-case string identifiers to align with CLI choices. 

15 """ 

16 

17 ALL = auto() 

18 

19 

20def normalize_tools_value(value: str | ToolsValue) -> ToolsValue: 

21 """Normalize a raw value to a ToolsValue enum. 

22 

23 Args: 

24 value: str or ToolsValue to normalize. 

25 

26 Returns: 

27 ToolsValue: Normalized enum value. 

28 

29 Raises: 

30 ValueError: If the value is not a valid tools value. 

31 """ 

32 if isinstance(value, ToolsValue): 

33 return value 

34 try: 

35 return ToolsValue[value.upper()] 

36 except KeyError as err: 

37 raise ValueError( 

38 f"Unknown tools value: {value!r}. Supported values: {list(ToolsValue)}", 

39 ) from err