mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-05 02:41:56 +00:00
style: satisfy strict-rule budget (ANN201, ANN401, TID251)
BerriAI/litellm CI's ruff strict-rule budget check flagged four new violations on the conduct shim. Fixes: - __init__.py: add return type annotation on initialize_guardrail (ANN201) - conduct.py: swap Any → object on __init__(*args, **kwargs) so the signature stays permissive without dynamically-typed Any (ANN401) - conduct.py: drop the now-unused Any import (TID251) Ruff --select ANN,TID passes locally.
This commit is contained in:
parent
a506f82297
commit
16bb91a05a
2 changed files with 3 additions and 3 deletions
|
|
@ -16,7 +16,7 @@ _DEFAULT_TIMEOUT_SECONDS = 8.0
|
||||||
_DEFAULT_UNREACHABLE_FALLBACK = "fail_closed"
|
_DEFAULT_UNREACHABLE_FALLBACK = "fail_closed"
|
||||||
|
|
||||||
|
|
||||||
def initialize_guardrail(litellm_params: "LitellmParams", guardrail: "Guardrail"):
|
def initialize_guardrail(litellm_params: "LitellmParams", guardrail: "Guardrail") -> ConductGuardrail:
|
||||||
"""Initialize the Conduct guardrail from LiteLLM's config block.
|
"""Initialize the Conduct guardrail from LiteLLM's config block.
|
||||||
|
|
||||||
Maps LiteLLM's typed guardrail fields onto the Conduct constructor:
|
Maps LiteLLM's typed guardrail fields onto the Conduct constructor:
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ Docs: https://conductai.ai/guard
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, ClassVar
|
from typing import ClassVar
|
||||||
|
|
||||||
from litellm.integrations.custom_guardrail import CustomGuardrail
|
from litellm.integrations.custom_guardrail import CustomGuardrail
|
||||||
from litellm.types.guardrails import GuardrailEventHooks
|
from litellm.types.guardrails import GuardrailEventHooks
|
||||||
|
|
@ -75,7 +75,7 @@ class ConductGuardrail(_ParentClass): # type: ignore[valid-type,misc]
|
||||||
# configurations — see veria-ai finding on BerriAI/litellm#38143.
|
# configurations — see veria-ai finding on BerriAI/litellm#38143.
|
||||||
SUPPORTED_EVENT_HOOKS: ClassVar[tuple[GuardrailEventHooks, ...]] = (GuardrailEventHooks.pre_call,)
|
SUPPORTED_EVENT_HOOKS: ClassVar[tuple[GuardrailEventHooks, ...]] = (GuardrailEventHooks.pre_call,)
|
||||||
|
|
||||||
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
def __init__(self, *args: object, **kwargs: object) -> None:
|
||||||
if _IMPORT_ERROR is not None or _BaseConductGuard is None:
|
if _IMPORT_ERROR is not None or _BaseConductGuard is None:
|
||||||
raise ImportError(_IMPORT_ERROR_MESSAGE) from _IMPORT_ERROR
|
raise ImportError(_IMPORT_ERROR_MESSAGE) from _IMPORT_ERROR
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue