fix(guardrails): annotate policy pipeline state casts
Some checks failed
LiteLLM Rust / rustfmt, clippy, test (push) Has been cancelled
Terraform Modules / fmt, validate, test (aws) (push) Has been cancelled

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Devin AI 2026-08-21 00:51:00 +00:00
parent 95427d3396
commit 4fd0cbffb5

View file

@ -432,12 +432,20 @@ def _policy_state_metadata(data: Mapping[str, object]) -> Mapping[str, object]:
def _policy_pipelines(data: Mapping[str, object]) -> tuple[tuple[str, "GuardrailPipeline"], ...]:
pipelines: Final = _policy_state_metadata(data).get("_guardrail_pipelines")
return tuple(cast("Sequence[tuple[str, GuardrailPipeline]]", pipelines)) if pipelines else ()
return (
tuple(cast("Sequence[tuple[str, GuardrailPipeline]]", pipelines)) # cast-ok: the policy engine wrote the slot
if pipelines
else ()
)
def _pipeline_managed_guardrail_names(data: Mapping[str, object]) -> frozenset[str]:
managed: Final = _policy_state_metadata(data).get("_pipeline_managed_guardrails")
return frozenset(cast("Collection[str]", managed)) if managed else frozenset()
return (
frozenset(cast("Collection[str]", managed)) # cast-ok: the policy engine wrote these guardrail names
if managed
else frozenset()
)
def _prompt_block_text(block: object) -> str: