Skip to content

Commit 044a43f

Browse files
committed
fix: fix code quality cjecks
1 parent 8e855ab commit 044a43f

4 files changed

Lines changed: 10 additions & 7 deletions

File tree

src/sap_cloud_sdk/adms/_async_http.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from __future__ import annotations
3030

3131
import asyncio
32+
import inspect
3233
from typing import Any, Callable, Dict, Optional
3334

3435
import httpx
@@ -216,7 +217,7 @@ async def _bearer_token(self) -> Optional[str]:
216217
"""Resolve the bearer token, handling both sync and async callables."""
217218
if self._get_token is None:
218219
return None
219-
if asyncio.iscoroutinefunction(self._get_token):
220+
if inspect.iscoroutinefunction(self._get_token):
220221
return await self._get_token()
221222
return await asyncio.to_thread(self._get_token)
222223

src/sap_cloud_sdk/core/data_anonymization/_http_transport.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ def _post_file_request(
182182
try:
183183
if request.file_path is not None:
184184
file_handle = open(request.file_path, "rb")
185-
file_value = file_handle
186-
else:
187-
file_value = request.file_content
188185

186+
file_value: BinaryIO | bytes = (
187+
file_handle if file_handle is not None else request.file_content or b""
188+
)
189189
files = {
190190
"file": (
191191
request.resolved_file_name(),

tests/core/unit/data_anonymization/test_http_transport.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ def test_resolve_cert_from_destination(
279279
transport._tmp_key_file = None
280280

281281
cert_path = transport._resolve_cert()
282+
assert isinstance(cert_path, str)
282283

283284
assert Path(cert_path).exists()
284285
assert "BEGIN RSA PRIVATE KEY" in Path(cert_path).read_text(encoding="utf-8")
@@ -328,6 +329,7 @@ def test_resolve_cert_from_destination_with_base64_bundle(
328329
transport._tmp_key_file = None
329330

330331
cert_path = transport._resolve_cert()
332+
assert isinstance(cert_path, str)
331333

332334
assert Path(cert_path).exists()
333335
assert "BEGIN CERTIFICATE" in Path(cert_path).read_text(encoding="utf-8")
@@ -373,7 +375,7 @@ def test_decode_destination_certificate_content_rejects_missing_key(self) -> Non
373375

374376
def test_resolve_cert_without_config_raises(self) -> None:
375377
transport = object.__new__(HttpTransport)
376-
transport._config = types.SimpleNamespace(
378+
transport._config = types.SimpleNamespace( # ty: ignore[invalid-assignment]
377379
cert=None,
378380
key=None,
379381
cert_path=None,

tests/objectstore/unit/test_s3_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_put_object_from_bytes_validation(self, mock_minio_class):
9696
@patch('sap_cloud_sdk.objectstore._s3.Minio')
9797
def test_put_object_from_bytes_s3_error(self, mock_minio_class):
9898
mock_minio = Mock()
99-
s3_error = S3Error("AccessDenied", "Access denied", "test.txt", "123", "456", Mock())
99+
s3_error = S3Error(Mock(), "AccessDenied", "Access denied", "test.txt", "123", "456")
100100
mock_minio.put_object.side_effect = s3_error
101101
mock_minio_class.return_value = mock_minio
102102

@@ -237,7 +237,7 @@ def test_list_objects_success(self, mock_minio_class):
237237
@patch('sap_cloud_sdk.objectstore._s3.Minio')
238238
def test_list_objects_s3_error(self, mock_minio_class):
239239
mock_minio = Mock()
240-
s3_error = S3Error("AccessDenied", "Access denied", "", "123", "456", Mock())
240+
s3_error = S3Error(Mock(), "AccessDenied", "Access denied", "", "123", "456")
241241
mock_minio.list_objects.side_effect = s3_error
242242
mock_minio_class.return_value = mock_minio
243243

0 commit comments

Comments
 (0)