product_spec.py 290 B

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