Skip to content

Commit 34d1bdd

Browse files
first round of reviews
1 parent b87a20a commit 34d1bdd

File tree

4 files changed

+32
-30
lines changed

4 files changed

+32
-30
lines changed

pyiceberg/catalog/hive.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,7 @@ def _init_thrift_transport(self) -> TTransport:
206206
password=password,
207207
)
208208
else:
209-
raise HiveAuthError(
210-
f"Unknown auth mechanism: {self._auth_mechanism!r}. "
211-
f"Valid values: NONE, KERBEROS, DIGEST-MD5"
212-
)
209+
raise HiveAuthError(f"Unknown auth mechanism: {self._auth_mechanism!r}. Valid values: NONE, KERBEROS, DIGEST-MD5")
213210

214211
def _client(self) -> Client:
215212
protocol = TBinaryProtocol.TBinaryProtocol(self._transport)

pyiceberg/utils/hadoop_credentials.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,5 @@ def read_hive_delegation_token() -> tuple[str, str]:
138138
)
139139

140140
raise HiveAuthError(
141-
f"No {HIVE_DELEGATION_TOKEN_KIND} found in token file: {token_file}. "
142-
f"File contains {num_tokens} token(s)."
141+
f"No {HIVE_DELEGATION_TOKEN_KIND} found in token file: {token_file}. File contains {num_tokens} token(s)."
143142
)

tests/catalog/test_hive.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import pytest
2828
import thrift.transport.TSocket
29-
from thrift.transport import TSocket, TTransport
3029
from hive_metastore.ttypes import (
3130
AlreadyExistsException,
3231
EnvironmentContext,
@@ -42,6 +41,7 @@
4241
)
4342
from hive_metastore.ttypes import Database as HiveDatabase
4443
from hive_metastore.ttypes import Table as HiveTable
44+
from thrift.transport import TSocket, TTransport
4545

4646
from pyiceberg.catalog import PropertiesUpdateSummary
4747
from pyiceberg.catalog.hive import (
@@ -1329,9 +1329,7 @@ def test_create_hive_client_success() -> None:
13291329

13301330
with patch("pyiceberg.catalog.hive._HiveClient", return_value=MagicMock()) as mock_hive_client:
13311331
client = HiveCatalog._create_hive_client(properties)
1332-
mock_hive_client.assert_called_once_with(
1333-
"thrift://localhost:10000", "user", False, "hive", auth_mechanism=None
1334-
)
1332+
mock_hive_client.assert_called_once_with("thrift://localhost:10000", "user", False, "hive", auth_mechanism=None)
13351333
assert client is not None
13361334

13371335

@@ -1344,9 +1342,7 @@ def test_create_hive_client_with_kerberos_success() -> None:
13441342
}
13451343
with patch("pyiceberg.catalog.hive._HiveClient", return_value=MagicMock()) as mock_hive_client:
13461344
client = HiveCatalog._create_hive_client(properties)
1347-
mock_hive_client.assert_called_once_with(
1348-
"thrift://localhost:10000", "user", True, "hiveuser", auth_mechanism=None
1349-
)
1345+
mock_hive_client.assert_called_once_with("thrift://localhost:10000", "user", True, "hiveuser", auth_mechanism=None)
13501346
assert client is not None
13511347

13521348

@@ -1358,10 +1354,12 @@ def test_create_hive_client_multiple_uris() -> None:
13581354

13591355
client = HiveCatalog._create_hive_client(properties)
13601356
assert mock_hive_client.call_count == 2
1361-
mock_hive_client.assert_has_calls([
1362-
call("thrift://localhost:10000", "user", False, "hive", auth_mechanism=None),
1363-
call("thrift://localhost:10001", "user", False, "hive", auth_mechanism=None),
1364-
])
1357+
mock_hive_client.assert_has_calls(
1358+
[
1359+
call("thrift://localhost:10000", "user", False, "hive", auth_mechanism=None),
1360+
call("thrift://localhost:10001", "user", False, "hive", auth_mechanism=None),
1361+
]
1362+
)
13651363
assert client is not None
13661364

13671365

tests/utils/test_hadoop_credentials.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,11 @@ def test_read_hadoop_text_invalid_utf8() -> None:
161161
def test_read_hive_delegation_token_valid(tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch) -> None:
162162
identifier = b"test-identifier-bytes"
163163
password = b"test-password-bytes"
164-
token_data = _build_token_file([
165-
(identifier, password, "HIVE_DELEGATION_TOKEN", "hive_service"),
166-
])
164+
token_data = _build_token_file(
165+
[
166+
(identifier, password, "HIVE_DELEGATION_TOKEN", "hive_service"),
167+
]
168+
)
167169

168170
token_file = tmp_path / "token_file"
169171
token_file.write_bytes(token_data)
@@ -179,10 +181,12 @@ def test_read_hive_delegation_token_multiple_tokens(tmp_path: pathlib.Path, monk
179181
"""The parser should find the HIVE_DELEGATION_TOKEN even if other tokens come first."""
180182
identifier = b"hive-id"
181183
password = b"hive-pw"
182-
token_data = _build_token_file([
183-
(b"hdfs-id", b"hdfs-pw", "HDFS_DELEGATION_TOKEN", "hdfs_service"),
184-
(identifier, password, "HIVE_DELEGATION_TOKEN", "hive_service"),
185-
])
184+
token_data = _build_token_file(
185+
[
186+
(b"hdfs-id", b"hdfs-pw", "HDFS_DELEGATION_TOKEN", "hdfs_service"),
187+
(identifier, password, "HIVE_DELEGATION_TOKEN", "hive_service"),
188+
]
189+
)
186190

187191
token_file = tmp_path / "token_file"
188192
token_file.write_bytes(token_data)
@@ -239,9 +243,11 @@ def test_read_hive_delegation_token_unsupported_version(tmp_path: pathlib.Path,
239243

240244

241245
def test_read_hive_delegation_token_no_hive_token(tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch) -> None:
242-
token_data = _build_token_file([
243-
(b"hdfs-id", b"hdfs-pw", "HDFS_DELEGATION_TOKEN", "hdfs_service"),
244-
])
246+
token_data = _build_token_file(
247+
[
248+
(b"hdfs-id", b"hdfs-pw", "HDFS_DELEGATION_TOKEN", "hdfs_service"),
249+
]
250+
)
245251

246252
token_file = tmp_path / "token_file"
247253
token_file.write_bytes(token_data)
@@ -253,9 +259,11 @@ def test_read_hive_delegation_token_no_hive_token(tmp_path: pathlib.Path, monkey
253259

254260
def test_read_hive_delegation_token_truncated(tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch) -> None:
255261
# Build a valid file and then truncate it
256-
token_data = _build_token_file([
257-
(b"test-id", b"test-pw", "HIVE_DELEGATION_TOKEN", "hive_service"),
258-
])
262+
token_data = _build_token_file(
263+
[
264+
(b"test-id", b"test-pw", "HIVE_DELEGATION_TOKEN", "hive_service"),
265+
]
266+
)
259267
truncated = token_data[:10] # Cut off in the middle
260268

261269
token_file = tmp_path / "token_file"

0 commit comments

Comments
 (0)