Skip to content

Commit 098213f

Browse files
committed
lint: ruff
1 parent fcb1ea7 commit 098213f

File tree

6 files changed

+25
-21
lines changed

6 files changed

+25
-21
lines changed

datacrunch/InferenceClient/inference_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def output(self, is_text: bool = False) -> Any:
8181
raise InferenceClientError(
8282
'Response might be a stream, use the stream method instead'
8383
) from e
84-
raise InferenceClientError(f'Failed to parse response as JSON: {str(e)}') from e
84+
raise InferenceClientError(f'Failed to parse response as JSON: {e!s}') from e
8585

8686
def stream(self, chunk_size: int = 512, as_text: bool = True) -> Generator[Any, None, None]:
8787
"""Stream the response content.
@@ -228,7 +228,7 @@ def _make_request(self, method: str, path: str, **kwargs) -> requests.Response:
228228
f'Request to {path} timed out after {timeout} seconds'
229229
) from e
230230
except requests.exceptions.RequestException as e:
231-
raise InferenceClientError(f'Request to {path} failed: {str(e)}') from e
231+
raise InferenceClientError(f'Request to {path} failed: {e!s}') from e
232232

233233
def run_sync(
234234
self,
@@ -458,7 +458,7 @@ def health(self, healthcheck_path: str = '/health') -> requests.Response:
458458
try:
459459
return self.get(healthcheck_path)
460460
except InferenceClientError as e:
461-
raise InferenceClientError(f'Health check failed: {str(e)}') from e
461+
raise InferenceClientError(f'Health check failed: {e!s}') from e
462462

463463

464464
@dataclass_json(undefined=Undefined.EXCLUDE)

datacrunch/containers/containers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def __str__(self):
386386
# Get all attributes except _inference_client
387387
attrs = {k: v for k, v in self.__dict__.items() if k != '_inference_client'}
388388
# Format each attribute
389-
attr_strs = [f'{k}={repr(v)}' for k, v in attrs.items()]
389+
attr_strs = [f'{k}={v!r}' for k, v in attrs.items()]
390390
return f'Deployment({", ".join(attr_strs)})'
391391

392392
def __repr__(self):
@@ -399,7 +399,7 @@ def __repr__(self):
399399

400400
@classmethod
401401
def from_dict_with_inference_key(
402-
cls, data: dict[str, Any], inference_key: str = None
402+
cls, data: dict[str, Any], inference_key: str | None = None
403403
) -> 'Deployment':
404404
"""Creates a Deployment instance from a dictionary with an inference key.
405405
@@ -731,7 +731,7 @@ class ContainersService:
731731
deployment API, including CRUD operations for deployments and related resources.
732732
"""
733733

734-
def __init__(self, http_client: HTTPClient, inference_key: str = None) -> None:
734+
def __init__(self, http_client: HTTPClient, inference_key: str | None = None) -> None:
735735
"""Initializes the containers service.
736736
737737
Args:
@@ -987,7 +987,7 @@ def delete_deployment_environment_variables(
987987
return result
988988

989989
def get_compute_resources(
990-
self, size: int = None, is_available: bool = None
990+
self, size: int | None = None, is_available: bool | None = None
991991
) -> list[ComputeResource]:
992992
"""Retrieves compute resources, optionally filtered by size and availability.
993993

datacrunch/datacrunch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(
2222
client_id: str,
2323
client_secret: str,
2424
base_url: str = 'https://api.datacrunch.io/v1',
25-
inference_key: str = None,
25+
inference_key: str | None = None,
2626
) -> None:
2727
"""The DataCrunch client.
2828

datacrunch/helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ def stringify_class_object_properties(class_object: type) -> str:
1010
:rtype: json string representation of a class object's properties and values
1111
"""
1212
class_properties = {
13-
property: getattr(class_object, property, '') # noqa: A001
14-
for property in class_object.__dir__() # noqa: A001
13+
property: getattr(class_object, property, '')
14+
for property in class_object.__dir__() # noqa: A001
1515
if property[:1] != '_' and type(getattr(class_object, property, '')).__name__ != 'method'
1616
}
1717
return json.dumps(class_properties, indent=2)

datacrunch/http_client/http_client.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ def __init__(self, auth_service, base_url: str) -> None:
3333
self._auth_service = auth_service
3434
self._auth_service.authenticate()
3535

36-
def post(self, url: str, json: dict = None, params: dict = None, **kwargs) -> requests.Response:
36+
def post(
37+
self, url: str, json: dict | None = None, params: dict | None = None, **kwargs
38+
) -> requests.Response:
3739
"""Sends a POST request.
3840
3941
A wrapper for the requests.post method.
@@ -62,7 +64,9 @@ def post(self, url: str, json: dict = None, params: dict = None, **kwargs) -> re
6264

6365
return response
6466

65-
def put(self, url: str, json: dict = None, params: dict = None, **kwargs) -> requests.Response:
67+
def put(
68+
self, url: str, json: dict | None = None, params: dict | None = None, **kwargs
69+
) -> requests.Response:
6670
"""Sends a PUT request.
6771
6872
A wrapper for the requests.put method.
@@ -91,7 +95,7 @@ def put(self, url: str, json: dict = None, params: dict = None, **kwargs) -> req
9195

9296
return response
9397

94-
def get(self, url: str, params: dict = None, **kwargs) -> requests.Response:
98+
def get(self, url: str, params: dict | None = None, **kwargs) -> requests.Response:
9599
"""Sends a GET request.
96100
97101
A wrapper for the requests.get method.
@@ -119,7 +123,7 @@ def get(self, url: str, params: dict = None, **kwargs) -> requests.Response:
119123
return response
120124

121125
def patch(
122-
self, url: str, json: dict = None, params: dict = None, **kwargs
126+
self, url: str, json: dict | None = None, params: dict | None = None, **kwargs
123127
) -> requests.Response:
124128
"""Sends a PATCH request.
125129
@@ -150,7 +154,7 @@ def patch(
150154
return response
151155

152156
def delete(
153-
self, url: str, json: dict = None, params: dict = None, **kwargs
157+
self, url: str, json: dict | None = None, params: dict | None = None, **kwargs
154158
) -> requests.Response:
155159
"""Sends a DELETE request.
156160

datacrunch/volumes/volumes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ def __init__(
1616
type: str,
1717
is_os_volume: bool,
1818
created_at: str,
19-
target: str = None,
19+
target: str | None = None,
2020
location: str = Locations.FIN_03,
21-
instance_id: str = None,
21+
instance_id: str | None = None,
2222
ssh_key_ids: list[str] = [],
23-
deleted_at: str = None,
23+
deleted_at: str | None = None,
2424
) -> None:
2525
"""Initialize the volume object.
2626
@@ -209,7 +209,7 @@ class VolumesService:
209209
def __init__(self, http_client) -> None:
210210
self._http_client = http_client
211211

212-
def get(self, status: str = None) -> list[Volume]:
212+
def get(self, status: str | None = None) -> list[Volume]:
213213
"""Get all of the client's non-deleted volumes, or volumes with specific status.
214214
215215
:param status: optional, status of the volumes, defaults to None
@@ -247,7 +247,7 @@ def create(
247247
type: str,
248248
name: str,
249249
size: int,
250-
instance_id: str = None,
250+
instance_id: str | None = None,
251251
location: str = Locations.FIN_03,
252252
) -> Volume:
253253
"""Create new volume.
@@ -311,7 +311,7 @@ def detach(self, id_list: list[str] | str) -> None:
311311
self._http_client.put(VOLUMES_ENDPOINT, json=payload)
312312
return
313313

314-
def clone(self, id: str, name: str = None, type: str = None) -> Volume:
314+
def clone(self, id: str, name: str | None = None, type: str | None = None) -> Volume:
315315
"""Clone a volume or multiple volumes.
316316
317317
:param id: volume id or list of volume ids

0 commit comments

Comments
 (0)