From cb9aeab01de299f10f36dbf94be9af49f51f56e2 Mon Sep 17 00:00:00 2001 From: Daniel JB Clark Date: Sat, 3 Oct 2026 12:48:53 -0400 Subject: [PATCH] fix(clinepass): type logging_obj and encoding instead of Any The `lint` job's failing step was not plain ruff but `scripts/ruff_strict_gate.py`, a strict-rule budget gate that compares totals against the base commit: "ANN401: total 361 over limit 119 (this change added 2)", pointing at transformation.py:192 and :197. Those two were `logging_obj: Any` and `encoding: Any`. The base class already types them (`litellm/llms/base_llm/chat/transformation.py:350,355`), so they now use `LiteLLMLoggingObj` and `"Tokenizer | None"`, imported under TYPE_CHECKING with an `Any` fallback exactly as litellm/llms/openai/chat/gpt_transformation.py does -- importing litellm_logging at runtime from a provider module risks a circular import, which is presumably why that pattern exists. This was also codex review finding #6, which said to "use the existing logging/tokenizer types as current CometAPI and Perplexity transformations do". I had read that as satisfied by the builtin-generics work and it was not. `scripts/ruff_strict_gate.py --base upstream/main` now reports "OK: every strict rule is within its codebase ceiling"; ruff clean under both CI configurations; 43 tests pass. Co-Authored-By: Claude Opus 5 --- litellm/llms/clinepass/chat/transformation.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/litellm/llms/clinepass/chat/transformation.py b/litellm/llms/clinepass/chat/transformation.py index 9a78695dacb..f4dc9d13bd3 100644 --- a/litellm/llms/clinepass/chat/transformation.py +++ b/litellm/llms/clinepass/chat/transformation.py @@ -15,7 +15,7 @@ Documentation: https://docs.cline.bot/ """ import json -from typing import Any, Final +from typing import TYPE_CHECKING, Any, Final import httpx @@ -27,6 +27,17 @@ from litellm.types.utils import ModelResponse from ...openai.chat.gpt_transformation import OpenAIGPTConfig from ..common_utils import ClinePassException +# Mirrors litellm/llms/openai/chat/gpt_transformation.py: these are needed only +# for annotations, and importing litellm_logging at runtime from a provider +# module risks a circular import. +if TYPE_CHECKING: + from litellm.litellm_core_utils.litellm_logging import Logging as _LiteLLMLoggingObj + from litellm.litellm_core_utils.tokenizer import Encoding as Tokenizer + + LiteLLMLoggingObj = _LiteLLMLoggingObj +else: + LiteLLMLoggingObj = Any + CLINEPASS_API_BASE: Final = "https://api.cline.bot/api/v1" # ClinePass nests the completion under this key on non-streaming responses. @@ -189,12 +200,12 @@ class ClinePassConfig(OpenAIGPTConfig): model: str, raw_response: httpx.Response, model_response: ModelResponse, - logging_obj: Any, + logging_obj: LiteLLMLoggingObj, request_data: dict, messages: list[AllMessageValues], optional_params: dict, litellm_params: dict, - encoding: Any, + encoding: "Tokenizer | None", api_key: str | None = None, json_mode: bool | None = None, ) -> ModelResponse: