mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-11 03:38:38 +00:00
fix(lint): stay within the basedpyright budget
Some checks failed
LiteLLM Rust / rust-lint (push) Waiting to run
LiteLLM Rust / rust-test (push) Waiting to run
LiteLLM Rust / rust-wheel (push) Waiting to run
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled
Some checks failed
LiteLLM Rust / rust-lint (push) Waiting to run
LiteLLM Rust / rust-test (push) Waiting to run
LiteLLM Rust / rust-wheel (push) Waiting to run
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled
- drop a Final annotation assigned inside the validation loop (reportGeneralTypeIssues over ceiling by one) - rename the PR-introduced _configured_event_hooks to public configured_event_hooks; its cross-module import added the two reportPrivateUsage errors that pushed the rule over its ceiling
This commit is contained in:
parent
8f7932ec5f
commit
7d293a6e20
3 changed files with 9 additions and 9 deletions
|
|
@ -36,7 +36,7 @@ from litellm.proxy.guardrails.guardrail_hooks.custom_code.sandbox import (
|
|||
)
|
||||
from litellm.proxy.guardrails.guardrail_registry import (
|
||||
GuardrailRegistry,
|
||||
_configured_event_hooks,
|
||||
configured_event_hooks,
|
||||
contains_encrypted_marker,
|
||||
decrypt_guardrail_litellm_params,
|
||||
encrypt_guardrail_litellm_params,
|
||||
|
|
@ -1280,7 +1280,7 @@ async def patch_guardrail(
|
|||
clear_stored_scope: Final = (
|
||||
"logging_only_scope" not in requested_litellm_params
|
||||
and parsed_litellm_params.logging_only_scope is not None
|
||||
and GuardrailEventHooks.logging_only.value not in _configured_event_hooks(parsed_litellm_params.mode)
|
||||
and GuardrailEventHooks.logging_only.value not in configured_event_hooks(parsed_litellm_params.mode)
|
||||
)
|
||||
litellm_params: Final = (
|
||||
LitellmParams(**MappingProxyType({**merged_litellm_params, "logging_only_scope": None}))
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ _MCP_EVENT_HOOKS: Final = frozenset(
|
|||
)
|
||||
|
||||
|
||||
def _configured_event_hooks(mode: str | list[str] | Mode) -> tuple[str, ...]:
|
||||
def configured_event_hooks(mode: str | list[str] | Mode) -> tuple[str, ...]:
|
||||
if isinstance(mode, str):
|
||||
return (mode,)
|
||||
if isinstance(mode, list):
|
||||
|
|
@ -114,7 +114,7 @@ def _configured_event_hooks(mode: str | list[str] | Mode) -> tuple[str, ...]:
|
|||
|
||||
|
||||
def _is_mcp_only_mode(mode: str | list[str] | Mode) -> bool:
|
||||
hooks: Final = _configured_event_hooks(mode)
|
||||
hooks: Final = configured_event_hooks(mode)
|
||||
return bool(hooks) and all(hook in _MCP_EVENT_HOOKS for hook in hooks)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ from .guardrail_hooks.llm_as_a_judge import (
|
|||
initialize_guardrail as initialize_llm_as_a_judge,
|
||||
)
|
||||
from .guardrail_initializers import (
|
||||
_configured_event_hooks,
|
||||
configured_event_hooks,
|
||||
initialize_bedrock,
|
||||
initialize_hide_secrets,
|
||||
initialize_lakera,
|
||||
|
|
@ -578,7 +578,7 @@ def _logging_only_scope_error(
|
|||
custom_guardrail_callback: CustomGuardrail, guardrail_name: str, litellm_params: LitellmParams
|
||||
) -> str | None:
|
||||
logging_only_scope: Final = litellm_params.logging_only_scope
|
||||
if logging_only_scope is not None and GuardrailEventHooks.logging_only.value not in _configured_event_hooks(
|
||||
if logging_only_scope is not None and GuardrailEventHooks.logging_only.value not in configured_event_hooks(
|
||||
litellm_params.mode
|
||||
):
|
||||
return (
|
||||
|
|
@ -823,9 +823,9 @@ class InMemoryGuardrailHandler:
|
|||
litellm_params: Final = LitellmParams(**params) if isinstance(params, dict) else params
|
||||
guardrail_name: Final = guardrail.get("guardrail_name", "Unknown")
|
||||
for custom_guardrail_callback in self._tracked_callbacks(guardrail_id):
|
||||
error: Final = _logging_only_scope_error(custom_guardrail_callback, guardrail_name, litellm_params)
|
||||
if error is not None:
|
||||
raise ValueError(error)
|
||||
scope_error = _logging_only_scope_error(custom_guardrail_callback, guardrail_name, litellm_params)
|
||||
if scope_error is not None:
|
||||
raise ValueError(scope_error)
|
||||
|
||||
def initialize_custom_guardrail(
|
||||
self,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue