Harden formatter preset normalization

This commit is contained in:
2026-06-27 14:07:38 +02:00
parent c34886b362
commit 0289a94153
3 changed files with 26 additions and 0 deletions
+6
View File
@@ -77,7 +77,12 @@ def normalize_detail_level(value: str) -> str:
return detail_policy.normalize_detail_level(value)
def _choice_key(value: Any) -> str:
return str(value or "").strip().lower().replace("-", "_").replace(" ", "_")
def normalize_style_policy(value: str) -> str:
value = _choice_key(value)
return value if value in STYLE_POLICIES else "drop_style_tail"
@@ -90,6 +95,7 @@ def caption_profile_choices() -> list[str]:
def normalize_caption_profile(value: str) -> str:
value = _choice_key(value)
return value if value in CAPTION_PROFILES else CAPTION_PROFILE_DEFAULT