Skip to content

Commit 907d526

Browse files
committed
lint: bugbear
1 parent df169b6 commit 907d526

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

datacrunch/InferenceClient/inference_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def output(self, is_text: bool = False) -> Any:
7474
if self._is_stream_response(self._original_response.headers):
7575
raise InferenceClientError(
7676
'Response might be a stream, use the stream method instead'
77-
)
78-
raise InferenceClientError(f'Failed to parse response as JSON: {str(e)}')
77+
) from e
78+
raise InferenceClientError(f'Failed to parse response as JSON: {str(e)}') from e
7979

8080
def stream(self, chunk_size: int = 512, as_text: bool = True) -> Generator[Any, None, None]:
8181
"""Stream the response content.
@@ -222,10 +222,10 @@ def _make_request(self, method: str, path: str, **kwargs) -> requests.Response:
222222
)
223223
response.raise_for_status()
224224
return response
225-
except requests.exceptions.Timeout:
226-
raise InferenceClientError(f'Request to {path} timed out after {timeout} seconds')
225+
except requests.exceptions.Timeout as e:
226+
raise InferenceClientError(f'Request to {path} timed out after {timeout} seconds') from e
227227
except requests.exceptions.RequestException as e:
228-
raise InferenceClientError(f'Request to {path} failed: {str(e)}')
228+
raise InferenceClientError(f'Request to {path} failed: {str(e)}') from e
229229

230230
def run_sync(
231231
self,
@@ -449,7 +449,7 @@ def health(self, healthcheck_path: str = '/health') -> requests.Response:
449449
try:
450450
return self.get(healthcheck_path)
451451
except InferenceClientError as e:
452-
raise InferenceClientError(f'Health check failed: {str(e)}')
452+
raise InferenceClientError(f'Health check failed: {str(e)}') from e
453453

454454

455455
@dataclass_json(undefined=Undefined.EXCLUDE)

examples/containers/container_deployments_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def wait_for_deployment_health(
5757
Returns:
5858
bool: True if deployment is healthy, False otherwise
5959
"""
60-
for attempt in range(max_attempts):
60+
for _attempt in range(max_attempts):
6161
try:
6262
status = client.containers.get_deployment_status(deployment_name)
6363
print(f'Deployment status: {status}')

0 commit comments

Comments
 (0)