Skip to content

Commit

Permalink
chore(azure): fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertCraigie committed Jul 15, 2024
1 parent 47d2fab commit d735816
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/openai/lib/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .._types import NOT_GIVEN, Omit, Timeout, NotGiven
from .._utils import is_given, is_mapping
from .._client import OpenAI, AsyncOpenAI
from .._compat import model_copy
from .._models import FinalRequestOptions
from .._streaming import Stream, AsyncStream
from .._exceptions import OpenAIError
Expand Down Expand Up @@ -281,8 +282,10 @@ def _get_azure_ad_token(self) -> str | None:
return None

@override
def _prepare_options(self, options: FinalRequestOptions) -> None:
def _prepare_options(self, options: FinalRequestOptions) -> FinalRequestOptions:
headers: dict[str, str | Omit] = {**options.headers} if is_given(options.headers) else {}

options = model_copy(options)
options.headers = headers

azure_ad_token = self._get_azure_ad_token()
Expand All @@ -296,7 +299,7 @@ def _prepare_options(self, options: FinalRequestOptions) -> None:
# should never be hit
raise ValueError("Unable to handle auth")

return super()._prepare_options(options)
return options


class AsyncAzureOpenAI(BaseAzureClient[httpx.AsyncClient, AsyncStream[Any]], AsyncOpenAI):
Expand Down Expand Up @@ -524,8 +527,10 @@ async def _get_azure_ad_token(self) -> str | None:
return None

@override
async def _prepare_options(self, options: FinalRequestOptions) -> None:
async def _prepare_options(self, options: FinalRequestOptions) -> FinalRequestOptions:
headers: dict[str, str | Omit] = {**options.headers} if is_given(options.headers) else {}

options = model_copy(options)
options.headers = headers

azure_ad_token = await self._get_azure_ad_token()
Expand All @@ -539,4 +544,4 @@ async def _prepare_options(self, options: FinalRequestOptions) -> None:
# should never be hit
raise ValueError("Unable to handle auth")

return await super()._prepare_options(options)
return options

0 comments on commit d735816

Please sign in to comment.