From a765188dc7125662365eb7c66eb3874b5d5dc288 Mon Sep 17 00:00:00 2001 From: Caduri Katzav Date: Thu, 1 Oct 2026 17:54:56 +0300 Subject: [PATCH] refactor(guardrails): end the record scope match with a final assert_never CodeQL does not treat a case _ arm as making the match exhaustive, so it flagged a possible implicit None return. The match now covers the three scopes and returns assert_never after it, as other matches in the repo do --- .../guardrail_hooks/generic_guardrail_api/record_scope.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/litellm/proxy/guardrails/guardrail_hooks/generic_guardrail_api/record_scope.py b/litellm/proxy/guardrails/guardrail_hooks/generic_guardrail_api/record_scope.py index 5cc8a93192f..4ed2dcf83a3 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/generic_guardrail_api/record_scope.py +++ b/litellm/proxy/guardrails/guardrail_hooks/generic_guardrail_api/record_scope.py @@ -85,8 +85,7 @@ class RecordScope: return False case "per_session": return session_id is None or self._claim_session(json.dumps((*caller, session_id, input_type))) - case _: - return assert_never(self._scope) + return assert_never(self._scope) def _claim_session(self, key: str) -> bool: if self._recorded_sessions.get_cache(key) is True: