diff --git a/litellm/llms/anthropic/experimental_pass_through/messages/fake_stream_iterator.py b/litellm/llms/anthropic/experimental_pass_through/messages/fake_stream_iterator.py index 7a55c14250a..4131483efbb 100644 --- a/litellm/llms/anthropic/experimental_pass_through/messages/fake_stream_iterator.py +++ b/litellm/llms/anthropic/experimental_pass_through/messages/fake_stream_iterator.py @@ -251,5 +251,5 @@ class FakeAnthropicMessagesStreamIterator: def __del__(self) -> None: try: self.close() - except Exception: + except Exception: # noqa: BLE001 # destructors cannot safely propagate cleanup failures pass diff --git a/litellm/rust_bridge/_lifecycle.py b/litellm/rust_bridge/_lifecycle.py index d3f4636789d..2b5deee67d7 100644 --- a/litellm/rust_bridge/_lifecycle.py +++ b/litellm/rust_bridge/_lifecycle.py @@ -61,7 +61,7 @@ class MutableLifecycleHost(LifecycleHost, Protocol): def advance_host(host: MutableLifecycleHost, outcome: NativeOutcome, error: BaseException | None) -> None: if error is not None and host.end is None: - host.end = datetime.now() + host.end = datetime.now() # noqa: DTZ005 # lifecycle timestamps preserve Logging's naive timestamp contract if host.logger is None: host.logger = host.arguments.get(LOGGING_OBJECT_KEY) replace: Final = host.machine.advance( @@ -103,7 +103,7 @@ async def deployment_failure(arguments: dict[str, object], error: BaseException from litellm import utils if not isinstance(error, Exception): - raise RuntimeError("native lifecycle failure did not retain an exception") + raise TypeError("native lifecycle failure did not retain an exception") await utils.async_post_call_failure_deployment_hook(arguments, error, call_type) @@ -130,9 +130,9 @@ def drive_sync(host: LifecycleHost) -> object: while host.machine.complete() is None: try: _invoke_sync(host) - except Exception as error: + except Exception as error: # noqa: BLE001 # lifecycle converts every ordinary host failure into a machine outcome host.advance(NativeOutcome.FAILURE, error) - except BaseException as error: + except BaseException as error: # noqa: BLE001 # cancellation and interrupts must advance the machine as aborts host.advance(NativeOutcome.ABORT, error) else: host.advance(NativeOutcome.SUCCESS) @@ -143,9 +143,9 @@ async def drive_async(host: LifecycleHost) -> object: while host.machine.complete() is None: try: await _invoke_async(host) - except Exception as error: + except Exception as error: # noqa: BLE001 # lifecycle converts every ordinary host failure into a machine outcome host.advance(NativeOutcome.FAILURE, error) - except BaseException as error: + except BaseException as error: # noqa: BLE001 # cancellation and interrupts must advance the machine as aborts host.advance(NativeOutcome.ABORT, error) else: host.advance(NativeOutcome.SUCCESS) diff --git a/litellm/rust_bridge/chat_completions.py b/litellm/rust_bridge/chat_completions.py index 3cbadcaebfe..b229d7597ee 100644 --- a/litellm/rust_bridge/chat_completions.py +++ b/litellm/rust_bridge/chat_completions.py @@ -624,7 +624,7 @@ class _ChatCompletionsHost: self.state: object | None = None self.response: object = None self.error: BaseException | None = None - self.start: datetime = datetime.now() + self.start: datetime = datetime.now() # noqa: DTZ005 # Logging preserves the legacy naive timestamp contract self.end: datetime | None = None def invoke(self) -> tuple[bool, object]: @@ -648,14 +648,14 @@ class _ChatCompletionsHost: if not isinstance(model_response, ModelResponse): raise TypeError("chat completions model_response must be a ModelResponse") self.response = build_model_response(self.bindings.send_sync(self.state), model_response) - self.end = datetime.now() + self.end = datetime.now() # noqa: DTZ005 # Logging preserves the legacy naive timestamp contract async def send(self) -> None: model_response: Final = self.arguments["model_response"] if not isinstance(model_response, ModelResponse): raise TypeError("chat completions model_response must be a ModelResponse") self.response = build_model_response(await self.bindings.send(self.state), model_response) - self.end = datetime.now() + self.end = datetime.now() # noqa: DTZ005 # Logging preserves the legacy naive timestamp contract async def deployment_success(self) -> None: from litellm.types.utils import CallTypes diff --git a/litellm/rust_bridge/messages.py b/litellm/rust_bridge/messages.py index 2f7e25a3770..089aa53f7b0 100644 --- a/litellm/rust_bridge/messages.py +++ b/litellm/rust_bridge/messages.py @@ -247,7 +247,7 @@ class _MessagesHost: self.state: object | None = None self.response: object = None self.error: BaseException | None = None - self.start: datetime = datetime.now() + self.start: datetime = datetime.now() # noqa: DTZ005 # Logging preserves the legacy naive timestamp contract self.end: datetime | None = None self.streaming: bool = False @@ -272,11 +272,11 @@ class _MessagesHost: def send_sync(self) -> None: self.response = self.bindings.send_sync(self.state) - self.end = datetime.now() + self.end = datetime.now() # noqa: DTZ005 # Logging preserves the legacy naive timestamp contract async def send(self) -> None: self.response = await self.bindings.send(self.state) - self.end = datetime.now() + self.end = datetime.now() # noqa: DTZ005 # Logging preserves the legacy naive timestamp contract async def deployment_success(self) -> None: from litellm.types.utils import CallTypes diff --git a/litellm/rust_bridge/ocr.py b/litellm/rust_bridge/ocr.py index e8391739c9c..748257d9e91 100644 --- a/litellm/rust_bridge/ocr.py +++ b/litellm/rust_bridge/ocr.py @@ -301,7 +301,7 @@ class _OcrHost: self.state: object | None = None self.response: object = None self.error: BaseException | None = None - self.start: datetime = datetime.now() + self.start: datetime = datetime.now() # noqa: DTZ005 # Logging preserves the legacy naive timestamp contract self.end: datetime | None = None def invoke(self) -> tuple[bool, object]: @@ -331,11 +331,11 @@ class _OcrHost: def send_sync(self) -> None: self.response = self.bindings.send_sync(self.state) - self.end = datetime.now() + self.end = datetime.now() # noqa: DTZ005 # Logging preserves the legacy naive timestamp contract async def send(self) -> None: self.response = self.bindings.finish(await self.bindings.send(self.state)) - self.end = datetime.now() + self.end = datetime.now() # noqa: DTZ005 # Logging preserves the legacy naive timestamp contract async def deployment_success(self) -> None: from litellm.types.utils import CallTypes