from typing import Any, Optional def normalize_product_spec(value: Any) -> Optional[str]: """空串/纯空白 -> None;否则 strip 后返回,最长 100。""" if value is None: return None s = str(value).strip() if not s: return None return s[:100]