From f18c649b5d7393966cae18bf3da6ec94f5ad515e Mon Sep 17 00:00:00 2001 From: Sudhi Seshachala Date: Mon, 24 Aug 2026 16:21:10 -0500 Subject: [PATCH] chore: fix ruff lint errors - Remove unused TYPE_CHECKING import (F401). - Un-quote self-forward-ref type annotation (UP037). - Suppress BLE001 on transport-fallback broad-except (intentional). --- .../proxy/guardrails/guardrail_hooks/conduct/conduct.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/litellm/proxy/guardrails/guardrail_hooks/conduct/conduct.py b/litellm/proxy/guardrails/guardrail_hooks/conduct/conduct.py index 62804cc196e..317d9d8a0df 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/conduct/conduct.py +++ b/litellm/proxy/guardrails/guardrail_hooks/conduct/conduct.py @@ -13,7 +13,7 @@ import hashlib import os import uuid from dataclasses import dataclass -from typing import TYPE_CHECKING, Any, Final, Literal +from typing import Any, Final, Literal from litellm._logging import verbose_proxy_logger from litellm.integrations.custom_guardrail import ( @@ -29,9 +29,6 @@ from litellm.types.guardrails import GuardrailEventHooks GUARDRAIL_NAME: Final = "conduct" -if TYPE_CHECKING: - from litellm.types.proxy.guardrails.guardrail_hooks.base import GuardrailConfigModel - Verdict = Literal["allow", "advisory", "warning", "block", "approval", "unknown"] FailMode = Literal["fail_open", "fail_closed"] @@ -48,7 +45,7 @@ class GuardDecision: message: str | None = None @classmethod - def parse(cls, text: str) -> "GuardDecision": + def parse(cls, text: str) -> GuardDecision: """Map the ``guard_check`` string envelope to a verdict. Response contract from Conduct: @@ -244,7 +241,7 @@ class ConductGuardrail(CustomGuardrail): if item.get("type") == "text": return GuardDecision.parse(item.get("text", "")) return GuardDecision(verdict="allow", raw="") - except Exception as e: + except Exception as e: # noqa: BLE001 — transport failure fallback path is intentionally broad verbose_proxy_logger.warning("conduct_guard: transport error %s — applying %s", e, self._fail_mode) if self._fail_mode == "fail_closed": return GuardDecision(