Coverage for lintro / enums / tool_name.py: 100%
40 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"""Canonical tool name definitions.
3Provides a stable set of identifiers for tools used across the codebase.
4"""
6from __future__ import annotations
8from enum import StrEnum, auto
11class ToolName(StrEnum):
12 """Supported tool identifiers in lower-case values."""
14 ACTIONLINT = auto()
15 ASTRO_CHECK = auto()
16 BANDIT = auto()
17 BLACK = auto()
18 CARGO_AUDIT = auto()
19 CARGO_DENY = auto()
20 CLIPPY = auto()
21 GITLEAKS = auto()
22 HADOLINT = auto()
23 MARKDOWNLINT = auto()
24 MYPY = auto()
25 OSV_SCANNER = auto()
26 OXFMT = auto()
27 OXLINT = auto()
28 PRETTIER = auto()
29 PYDOCLINT = auto()
30 PYTEST = auto()
31 RUFF = auto()
32 RUSTC = auto()
33 RUSTFMT = auto()
34 SEMGREP = auto()
35 SHELLCHECK = auto()
36 SHFMT = auto()
37 SQLFLUFF = auto()
38 SVELTE_CHECK = auto()
39 TAPLO = auto()
40 TSC = auto()
41 VUE_TSC = auto()
42 YAMLLINT = auto()
45def normalize_tool_name(value: str | ToolName) -> ToolName:
46 """Normalize a raw name to ToolName.
48 Args:
49 value: Tool name as str or ToolName.
51 Returns:
52 ToolName: Normalized enum member.
54 Raises:
55 ValueError: If the value is not a valid tool name.
56 """
57 if isinstance(value, ToolName):
58 return value
59 # Normalize hyphens to underscores (e.g., "astro-check" -> "astro_check")
60 normalized = value.strip().replace("-", "_")
61 try:
62 return ToolName[normalized.upper()]
63 except KeyError as err:
64 raise ValueError(
65 f"Unknown tool name: {value!r}. Supported tools: {list(ToolName)}",
66 ) from err