mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
style(ocr): use PEP 604 X | None annotations in rust_bridge
Converts Optional[X]/Union[...] to the X | None form so the new OCR code stays under the UP045 strict-rule budget gate (lint job). Safe at runtime — the module already has 'from __future__ import annotations'.
This commit is contained in:
parent
e70e3d6034
commit
8f305348fc
1 changed files with 7 additions and 7 deletions
|
|
@ -11,7 +11,7 @@ can import it statically without forming an import cycle.
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Final, Optional, Protocol, Union, cast
|
||||
from typing import Final, Protocol, cast
|
||||
|
||||
|
||||
class RustOcr(Protocol):
|
||||
|
|
@ -21,10 +21,10 @@ class RustOcr(Protocol):
|
|||
self,
|
||||
model: str,
|
||||
document: dict[str, object],
|
||||
api_key: Optional[str],
|
||||
api_base: Optional[str],
|
||||
api_key: str | None,
|
||||
api_base: str | None,
|
||||
optional_params: dict[str, object],
|
||||
timeout_seconds: Optional[float],
|
||||
timeout_seconds: float | None,
|
||||
) -> dict[str, object]: ...
|
||||
|
||||
|
||||
|
|
@ -35,11 +35,11 @@ class _Unset:
|
|||
_UNSET: Final[_Unset] = _Unset()
|
||||
|
||||
_rust_ocr_enabled = False
|
||||
_rust_ocr_impl: Optional[RustOcr] = None
|
||||
_rust_ocr_impl: RustOcr | None = None
|
||||
|
||||
|
||||
def use_litellm_rust(
|
||||
enabled: bool = True, *, ocr: Union[Optional[RustOcr], _Unset] = _UNSET
|
||||
enabled: bool = True, *, ocr: RustOcr | None | _Unset = _UNSET
|
||||
) -> None:
|
||||
"""Route supported OCR calls through the Rust ``litellm_python_bridge`` extension.
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ def rust_ocr_enabled() -> bool:
|
|||
return _rust_ocr_enabled
|
||||
|
||||
|
||||
def load_rust_ocr() -> Optional[RustOcr]:
|
||||
def load_rust_ocr() -> RustOcr | None:
|
||||
"""Return the Rust OCR callable, or ``None`` when no bridge is available.
|
||||
|
||||
Prefers an injected implementation, otherwise loads the compiled
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue