run_common.py 703 B

12345678910111213141516171819
  1. """Leaf constants shared by ``gateway/run.py`` and its ``run_*`` mixin modules.
  2. Kept import-cycle free (imports nothing from ``gateway.run``) because these values
  3. are used as default-argument sentinels, which must resolve at ``def`` time.
  4. """
  5. from typing import Any
  6. # Sentinel for "caller did not pass metadata" vs "caller passed None".
  7. _UNSET = object()
  8. def _csv_or_list_to_set(raw: Any) -> set[str]:
  9. """Normalize a config list or comma-separated scalar into a string set."""
  10. if raw is None:
  11. return set()
  12. if isinstance(raw, list):
  13. return {str(part).strip() for part in raw if str(part).strip()}
  14. return {part.strip() for part in str(raw).split(",") if part.strip()}