Skip to content

Commit 84acab1

Browse files
committed
Use kwargs instead of del
1 parent 03a5a94 commit 84acab1

File tree

1 file changed

+24
-28
lines changed

1 file changed

+24
-28
lines changed

tests/integration/dataframe/test_dataframe.py

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
import warnings
33
from datetime import datetime, timezone
4-
from typing import Callable, List, Optional
4+
from typing import Callable, List, Optional, TypedDict
55

66
import pytest # type: ignore
77
import responses
@@ -32,6 +32,10 @@
3232
from responses import matchers
3333

3434

35+
_TestResultIdArg = TypedDict(
36+
"_TestResultIdArg", {"test_result_id": Optional[str]}, total=False
37+
)
38+
3539
int_index_column = Column(
3640
name="index", data_type=DataType.Int32, column_type=ColumnType.Index
3741
)
@@ -248,17 +252,16 @@ def test__modify_table__returns(
248252

249253
client.modify_table(
250254
id,
251-
self._remove_test_result_id_if_not_supported(
252-
ModifyTableRequest(
253-
metadata_revision=2,
254-
name="Modified table",
255-
test_result_id="Test result",
256-
properties={"cow": "moo"},
257-
columns=[
258-
ColumnMetadataPatch(name="index", properties={"sheep": "baa"})
259-
],
255+
ModifyTableRequest(
256+
metadata_revision=2,
257+
name="Modified table",
258+
properties={"cow": "moo"},
259+
columns=[
260+
ColumnMetadataPatch(name="index", properties={"sheep": "baa"})
261+
],
262+
**self._test_result_id_if_supported(
263+
"Test result", supports_test_result_id
260264
),
261-
supports_test_result_id,
262265
),
263266
)
264267
table = client.get_table_metadata(id)
@@ -282,17 +285,12 @@ def test__modify_table__returns(
282285

283286
client.modify_table(
284287
id,
285-
self._remove_test_result_id_if_not_supported(
286-
ModifyTableRequest(
287-
metadata_revision=4,
288-
name=None,
289-
test_result_id=None,
290-
properties={"cow": None},
291-
columns=[
292-
ColumnMetadataPatch(name="index", properties={"sheep": None})
293-
],
294-
),
295-
supports_test_result_id,
288+
ModifyTableRequest(
289+
metadata_revision=4,
290+
name=None,
291+
properties={"cow": None},
292+
columns=[ColumnMetadataPatch(name="index", properties={"sheep": None})],
293+
**self._test_result_id_if_supported(None, supports_test_result_id),
296294
),
297295
)
298296
table = client.get_table_metadata(id)
@@ -304,12 +302,10 @@ def test__modify_table__returns(
304302
assert table.columns[0].properties == {}
305303

306304
@staticmethod
307-
def _remove_test_result_id_if_not_supported(
308-
model: ModifyTableRequest, supports_test_result_id: bool
309-
) -> ModifyTableRequest:
310-
if not supports_test_result_id:
311-
del model.test_result_id
312-
return model
305+
def _test_result_id_if_supported(
306+
test_result_id: Optional[str], supports_test_result_id: bool
307+
) -> _TestResultIdArg:
308+
return {"test_result_id": test_result_id} if supports_test_result_id else {}
313309

314310
def test__delete_table__deletes(self, client: DataFrameClient):
315311
id = client.create_table(

0 commit comments

Comments
 (0)