diff --git a/litellm/experimental_mcp_client/tools.py b/litellm/experimental_mcp_client/tools.py index a9ee851d529..8e640f8b837 100644 --- a/litellm/experimental_mcp_client/tools.py +++ b/litellm/experimental_mcp_client/tools.py @@ -129,8 +129,8 @@ async def list_tools_with_pagination( ) tools.extend(result.tools) - next_cursor = getattr(result, "next_cursor", None) - if not isinstance(next_cursor, str) or not next_cursor: + next_cursor = result.next_cursor + if not next_cursor: return tools if next_cursor in seen_cursors: verbose_logger.warning( diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index 5d9a1a3a6a2..b37159a5bbb 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -6446,11 +6446,11 @@ def get_standard_logging_object_payload( cost_breakdown=request_cost_breakdown, autorouter_savings=autorouter_savings, autorouter_savings_estimate=( - { + { # mutable-ok: spend-log JSON serialization requires plain mappings "version": 3, "status": "unknown", "reason": "pending_projection", - } # mutable-ok: spend-log JSON serialization requires plain mappings + } if captured_baseline is not None else ( { # mutable-ok: spend-log JSON serialization requires plain mappings diff --git a/litellm/llms/anthropic/chat/guardrail_translation/handler.py b/litellm/llms/anthropic/chat/guardrail_translation/handler.py index 03b562c3014..875c5274c9a 100644 --- a/litellm/llms/anthropic/chat/guardrail_translation/handler.py +++ b/litellm/llms/anthropic/chat/guardrail_translation/handler.py @@ -687,9 +687,7 @@ class AnthropicMessagesHandler(BaseTranslation): return data - def _hoisted_top_level_system_message( - self, data: dict - ) -> AllMessageValues | None: # mutable-ok: API message payload + def _hoisted_top_level_system_message(self, data: Mapping[str, object]) -> AllMessageValues | None: """Return the system message produced by translating the top-level prompt.""" system: Final = data.get("system") if not system: diff --git a/litellm/proxy/auth/auth_checks.py b/litellm/proxy/auth/auth_checks.py index 2ae285d6eef..da29364886e 100644 --- a/litellm/proxy/auth/auth_checks.py +++ b/litellm/proxy/auth/auth_checks.py @@ -4051,7 +4051,7 @@ async def get_org_object_for_request( ) except OrganizationNotFoundError: return None - except Exception as e: # noqa: BLE001 # only a DB outage may fail auth here, anything else degrades to no org limits + except Exception as e: if not PrismaDBExceptionHandler.is_database_service_unavailable_error_in_chain(e): verbose_proxy_logger.debug("org lookup failed, continuing without org limits", exc_info=True) return None diff --git a/litellm/proxy/db/baseline_accounting.py b/litellm/proxy/db/baseline_accounting.py index 8622cb9e481..4894f2e7583 100644 --- a/litellm/proxy/db/baseline_accounting.py +++ b/litellm/proxy/db/baseline_accounting.py @@ -470,12 +470,12 @@ class BaselineAccountingStore: async def _pages( self, db: SupportsRawQueries, scope: str, after_revision: int, withdraw_from: float | None = None ) -> AsyncIterator[tuple[_StoredRecord, ...]]: - cursor: float | None = None + cursor: float | None = None # rebind-ok: keyset pagination advances after each complete timestamp group while page := _RECORDS.validate_python( tuple(await db.query_raw(_READ_PAGE, scope, after_revision, cursor, _PAGE_TIMESTAMPS, withdraw_from)) ): yield page - cursor = page[-1].started_at # rebind-ok: keyset pagination advances after each complete timestamp group + cursor = page[-1].started_at async def _withdraw(self, db: SupportsRawQueries, scope: str, started_at: float) -> None: async for page in self._pages(db, scope, 0, withdraw_from=started_at): @@ -607,13 +607,13 @@ async def flush_baseline_accounting(client: PrismaClient) -> None: store: Final = BaselineAccountingStore.for_client(client) async with client.baseline_accounting_lock: batch: Final = tuple(client.baseline_accounting_transactions[:32]) - client.baseline_accounting_transactions = client.baseline_accounting_transactions[ + client.baseline_accounting_transactions = client.baseline_accounting_transactions[ # rebind-ok: drain under lock 32: - ] # rebind-ok: drain under lock + ] more_queued: Final = bool(client.baseline_accounting_transactions) try: remaining: Final = await asyncio.wait_for(_flush_records(store, batch), timeout=5) - except (Exception, asyncio.CancelledError) as error: # noqa: BLE001 # unknown acknowledgements can be replayed safely + except (Exception, asyncio.CancelledError) as error: async with client.baseline_accounting_lock: client.baseline_accounting_transactions.extend(batch) if isinstance(error, asyncio.CancelledError): diff --git a/litellm/proxy/hooks/autorouter_baseline_cache.py b/litellm/proxy/hooks/autorouter_baseline_cache.py index 8cea7d0e364..a21a250c6a4 100644 --- a/litellm/proxy/hooks/autorouter_baseline_cache.py +++ b/litellm/proxy/hooks/autorouter_baseline_cache.py @@ -230,12 +230,12 @@ class AutoRouterBaselineCache(CustomLogger): async def invalidate_baseline_cache(logging_obj: Logging, reason: str, *, completed: bool = False) -> None: context: Final = logging_obj.baseline_cache_context if context is not None: - logging_obj.baseline_cache_context = replace( + logging_obj.baseline_cache_context = replace( # rebind-ok: request-owned retry marker context, invalidated=reason - ) # rebind-ok: request-owned retry marker - logging_obj.baseline_observation = context.capture.model_copy( + ) + logging_obj.baseline_observation = context.capture.model_copy( # rebind-ok: uncertain capture for failure logs update=MappingProxyType( - { # rebind-ok: capture uncertainty for failure logging + { "observation": context.capture.observation.model_copy( update=MappingProxyType( {