Skip to content

Commit 318c9d3

Browse files
Gayathri Srividya RajavarapuGayathri Srividya Rajavarapu
authored andcommitted
fix: lint and type issues in rest catalog and tests
1 parent 5b7a160 commit 318c9d3

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

pyiceberg/catalog/rest/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,12 +451,14 @@ def _create_session(self) -> Session:
451451
raise ValueError(f"Failed to parse auth configuration as JSON from {source_env_var}: {raw_auth!r}") from e
452452
if not isinstance(auth_config, dict):
453453
raise ValueError(
454-
f"Auth configuration loaded from {source_env_var} must be a JSON object (dict), got {type(auth_config).__name__}: {raw_auth!r}"
454+
f"Auth configuration loaded from {source_env_var} must be a JSON object (dict), "
455+
f"got {type(auth_config).__name__}: {raw_auth!r}"
455456
)
456457
else:
457458
if not isinstance(raw_auth, dict):
458459
raise ValueError(
459-
f"Auth configuration for {source_env_var} must be a dict or JSON string, got {type(raw_auth).__name__}: {raw_auth!r}"
460+
f"Auth configuration for {source_env_var} must be a dict or JSON string, "
461+
f"got {type(raw_auth).__name__}: {raw_auth!r}"
460462
)
461463
auth_config = raw_auth
462464
auth_type = auth_config.get("type")
@@ -480,11 +482,13 @@ def _create_session(self) -> Session:
480482
)
481483
if auth_type == CUSTOM and not auth_impl:
482484
raise ValueError(
483-
f"auth.impl must be specified when using custom auth.type{f' (from {source_env_var})' if source_env_var else ''}"
485+
f"auth.impl must be specified when using custom auth.type"
486+
f"{f' (from {source_env_var})' if source_env_var else ''}"
484487
)
485488
if auth_type != CUSTOM and auth_impl:
486489
raise ValueError(
487-
f"auth.impl can only be specified when using custom auth.type{f' (from {source_env_var})' if source_env_var else ''}"
490+
f"auth.impl can only be specified when using custom auth.type"
491+
f"{f' (from {source_env_var})' if source_env_var else ''}"
488492
)
489493
self._auth_manager = AuthManagerFactory.create(auth_impl or auth_type, auth_type_config or {})
490494
session.auth = AuthManagerAdapter(self._auth_manager)

tests/catalog/test_rest.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3372,15 +3372,17 @@ def test_rest_catalog_with_flat_properties_edge_cases(
33723372
assert catalog.uri == TEST_URI
33733373
# If scope is a list, ensure it is handled as a space-separated string
33743374
if isinstance(expected_scopes, list):
3375-
assert any(scope in token_response["scope"] for scope in expected_scopes)
3375+
if token_response is not None:
3376+
assert any(scope in token_response["scope"] for scope in expected_scopes)
33763377
else:
3377-
assert token_response["scope"] == expected_scopes
3378+
if token_response is not None:
3379+
assert token_response["scope"] == expected_scopes
33783380
elif catalog_properties["auth.type"] == "google":
33793381
pytest.importorskip("google.auth", reason="google-auth is required for Google auth tests")
33803382
# Patch google.auth.load_credentials_from_file and google.auth.transport.requests.Request
33813383
with (
33823384
mock.patch("google.auth.load_credentials_from_file") as mock_load_creds,
3383-
mock.patch("google.auth.transport.requests.Request") as mock_google_request,
3385+
mock.patch("google.auth.transport.requests.Request"),
33843386
):
33853387
mock_credentials = mock.MagicMock()
33863388
mock_credentials.token = "file_token"

0 commit comments

Comments
 (0)