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
« prev ^ index » next coverage.py v7.13.0, created at 2026-04-03 18:53 +0000
1"""Tools value enum definitions.
3This module defines special values for tool selection.
4"""
6from __future__ import annotations
8from enum import StrEnum, auto
11class ToolsValue(StrEnum):
12 """Special values for tool selection.
14 Values are lower-case string identifiers to align with CLI choices.
15 """
17 ALL = auto()
20def normalize_tools_value(value: str | ToolsValue) -> ToolsValue:
21 """Normalize a raw value to a ToolsValue enum.
23 Args:
24 value: str or ToolsValue to normalize.
26 Returns:
27 ToolsValue: Normalized enum value.
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