Centralize formatter detail levels

This commit is contained in:
2026-06-27 13:56:21 +02:00
parent 6f6afb4d22
commit 333fa5eae6
8 changed files with 70 additions and 9 deletions
+23
View File
@@ -0,0 +1,23 @@
from __future__ import annotations
from typing import Any
DETAIL_LEVELS = ("balanced", "concise", "dense")
DEFAULT_DETAIL_LEVEL = "balanced"
def detail_level_choices() -> list[str]:
return list(DETAIL_LEVELS)
def normalize_detail_level(value: Any) -> str:
level = str(value or "").strip().lower().replace("-", "_").replace(" ", "_")
return level if level in DETAIL_LEVELS else DEFAULT_DETAIL_LEVEL
def detail_allows(level: Any, dense_only: bool = False) -> bool:
level = normalize_detail_level(level)
if dense_only:
return level == "dense"
return level != "concise"