mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
style(mcp): modern type annotations in the authorization_code arm and source
This commit is contained in:
parent
6710a8e49c
commit
f406b3a626
2 changed files with 4 additions and 6 deletions
|
|
@ -14,7 +14,6 @@ that each land in a follow-up PR with their seam. Pure v2: no imports from v1.
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Optional
|
||||
|
||||
import httpx
|
||||
from typing_extensions import assert_never
|
||||
|
|
@ -53,7 +52,7 @@ from litellm.proxy._experimental.mcp_server.outbound_credentials.types import (
|
|||
class _NullOAuthTokenStore:
|
||||
"""Fail-closed default: with no token store wired, every user reads as not authorized."""
|
||||
|
||||
async def fetch(self, user_id: str, server_id: str) -> Optional[OAuthToken]:
|
||||
async def fetch(self, user_id: str, server_id: str) -> OAuthToken | None:
|
||||
return None
|
||||
|
||||
|
||||
|
|
@ -65,7 +64,7 @@ class UpstreamCredentialProvider:
|
|||
`authorization_code` reads the user's token from the injected `OAuthTokenStore`.
|
||||
"""
|
||||
|
||||
def __init__(self, oauth_token_store: Optional[OAuthTokenStore] = None) -> None:
|
||||
def __init__(self, oauth_token_store: OAuthTokenStore | None = None) -> None:
|
||||
self._oauth_token_store: OAuthTokenStore = (
|
||||
oauth_token_store or _NullOAuthTokenStore()
|
||||
)
|
||||
|
|
@ -115,7 +114,7 @@ class UpstreamCredentialProvider:
|
|||
|
||||
async def _authz_token(
|
||||
self, subject: Subject, server: ServerSpec
|
||||
) -> Optional[OAuthToken]:
|
||||
) -> OAuthToken | None:
|
||||
"""The user's authorization_code token, or None when absent or the store is unreachable.
|
||||
|
||||
A store outage is mapped to None (the OAuth challenge), not raised, so a transient outage
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ It imports v1, so it is kept out of the package ``__init__`` like the rest of th
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from litellm.proxy._experimental.mcp_server.outbound_credentials.oauth_token_store import (
|
||||
OAuthToken,
|
||||
|
|
@ -24,7 +23,7 @@ class V1PerUserTokenStore:
|
|||
this never raises ``TokenStoreUnavailable``.
|
||||
"""
|
||||
|
||||
async def fetch(self, user_id: str, server_id: str) -> Optional[OAuthToken]:
|
||||
async def fetch(self, user_id: str, server_id: str) -> OAuthToken | None:
|
||||
if not user_id:
|
||||
return None
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue