Skip to content

Commit 45f04bd

Browse files
committed
Format and lint
1 parent 4d355e9 commit 45f04bd

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/openai/_exceptions.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
from __future__ import annotations
44

5-
from typing import TYPE_CHECKING, Any, Optional, cast
6-
from typing_extensions import Literal, Self
5+
from typing import TYPE_CHECKING, Any, Callable, Optional, cast
6+
from typing_extensions import Self, Literal, override
77

88
import httpx
99

@@ -67,11 +67,12 @@ def __init__(self, message: str, request: httpx.Request, *, body: object | None)
6767
self.type = None
6868

6969
@classmethod
70-
def _reconstruct(cls, message: str, request: httpx.Request, body: object | None) -> Self:
70+
def _reconstruct_base(cls, message: str, request: httpx.Request, body: object | None) -> Self:
7171
return cls(message, request, body=body)
7272

73-
def __reduce__(self) -> tuple[type[APIError], tuple[str, httpx.Request, object | None]]:
74-
return (self.__class__._reconstruct, (self.message, self.request, self.body))
73+
@override
74+
def __reduce__(self) -> tuple[Callable[..., Self], tuple[Any, ...]]:
75+
return (self.__class__._reconstruct_base, (self.message, self.request, self.body))
7576

7677

7778
class APIResponseValidationError(APIError):
@@ -87,7 +88,10 @@ def __init__(self, response: httpx.Response, body: object | None, *, message: st
8788
def _reconstruct(cls, response: httpx.Response, body: object | None, message: str | None) -> Self:
8889
return cls(response, body, message=message)
8990

90-
def __reduce__(self) -> tuple[type[APIResponseValidationError], tuple[httpx.Response, object | None, str | None]]:
91+
@override
92+
def __reduce__(
93+
self,
94+
) -> tuple[Callable[..., Self], tuple[Any, ...]]:
9195
return (self.__class__._reconstruct, (self.response, self.body, self.message))
9296

9397

@@ -108,7 +112,10 @@ def __init__(self, message: str, *, response: httpx.Response, body: object | Non
108112
def _reconstruct(cls, message: str, response: httpx.Response, body: object | None) -> Self:
109113
return cls(message, response=response, body=body)
110114

111-
def __reduce__(self) -> tuple[type[APIStatusError], tuple[str, httpx.Response, object | None]]:
115+
@override
116+
def __reduce__(
117+
self,
118+
) -> tuple[Callable[..., Self], tuple[Any, ...]]:
112119
return (self.__class__._reconstruct, (self.message, self.response, self.body))
113120

114121

@@ -120,7 +127,8 @@ def __init__(self, *, message: str = "Connection error.", request: httpx.Request
120127
def _reconstruct(cls, message: str, request: httpx.Request) -> Self:
121128
return cls(message=message, request=request)
122129

123-
def __reduce__(self) -> tuple[type[APIConnectionError], tuple[str, httpx.Request]]:
130+
@override
131+
def __reduce__(self) -> tuple[Callable[..., Self], tuple[Any, ...]]:
124132
return (self.__class__._reconstruct, (self.message, self.request))
125133

126134

@@ -181,7 +189,8 @@ def __init__(self, *, completion: ChatCompletion) -> None:
181189
def _reconstruct(cls, completion: ChatCompletion) -> Self:
182190
return cls(completion=completion)
183191

184-
def __reduce__(self) -> tuple[type[LengthFinishReasonError], tuple[ChatCompletion]]:
192+
@override
193+
def __reduce__(self) -> tuple[Callable[..., Self], tuple[Any, ...]]:
185194
return (self.__class__._reconstruct, (self.completion,))
186195

187196

0 commit comments

Comments
 (0)