Skip to content

Commit 2e7e4cb

Browse files
committed
fix: remove unnecessary whitespace and improve code formatting in maintenance and test files (ran: make lint)
1 parent 2fc6758 commit 2e7e4cb

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

pyiceberg/table/maintenance.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,11 @@ def expire_snapshots_with_retention_policy(
247247
"""
248248
# Get default values from table properties
249249
default_max_age, default_min_snapshots, _ = self._get_expiration_properties()
250-
250+
251251
# Use defaults from table properties if not explicitly provided
252252
if timestamp_ms is None:
253253
timestamp_ms = default_max_age
254-
254+
255255
if min_snapshots_to_keep is None:
256256
min_snapshots_to_keep = default_min_snapshots
257257

@@ -266,9 +266,7 @@ def expire_snapshots_with_retention_policy(
266266
raise ValueError("min_snapshots_to_keep must be at least 1")
267267

268268
snapshots_to_expire = self._get_snapshots_to_expire_with_retention(
269-
timestamp_ms=timestamp_ms,
270-
retain_last_n=retain_last_n,
271-
min_snapshots_to_keep=min_snapshots_to_keep
269+
timestamp_ms=timestamp_ms, retain_last_n=retain_last_n, min_snapshots_to_keep=min_snapshots_to_keep
272270
)
273271

274272
if snapshots_to_expire:

tests/table/test_dedup_data_file_filepaths.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import os
1818
import uuid
1919
from pathlib import Path
20-
from typing import List, Set, Generator
20+
from typing import Generator, List, Set
2121

2222
import pyarrow as pa
2323
import pyarrow.parquet as pq
@@ -35,7 +35,7 @@ def iceberg_catalog(tmp_path: Path) -> Generator[InMemoryCatalog, None, None]:
3535
catalog.create_namespace("default")
3636
yield catalog
3737
# Clean up SQLAlchemy engine connections
38-
if hasattr(catalog, 'engine'):
38+
if hasattr(catalog, "engine"):
3939
try:
4040
catalog.engine.dispose()
4141
except Exception:
@@ -92,9 +92,9 @@ def prepopulated_table(iceberg_catalog: InMemoryCatalog, dupe_data_file_path: Pa
9292
tx2.commit_transaction()
9393

9494
yield table
95-
95+
9696
# Cleanup table's catalog connections
97-
if hasattr(table, '_catalog') and hasattr(table._catalog, 'engine'):
97+
if hasattr(table, "_catalog") and hasattr(table._catalog, "engine"):
9898
try:
9999
table._catalog.engine.dispose()
100100
except Exception:
@@ -133,9 +133,9 @@ def test_get_all_datafiles_all_snapshots(prepopulated_table: Table, dupe_data_fi
133133
assert dupe_data_file_path.name in file_paths
134134
finally:
135135
# Ensure catalog connections are properly closed
136-
if hasattr(prepopulated_table, '_catalog'):
136+
if hasattr(prepopulated_table, "_catalog"):
137137
catalog = prepopulated_table._catalog
138-
if hasattr(catalog, '_connection') and catalog._connection is not None:
138+
if hasattr(catalog, "_connection") and catalog._connection is not None:
139139
try:
140140
catalog._connection.close()
141141
except Exception:

tests/table/test_retention_strategies.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def test_retain_last_n_snapshots(table_v2: Table) -> None:
3737
(5, 5000),
3838
]
3939
snapshots = _make_snapshots(ids_and_ts)
40-
40+
4141
# Save original catalog for cleanup
4242
original_catalog = table_v2.catalog
43-
43+
4444
try:
4545
table_v2.metadata = table_v2.metadata.model_copy(update={"snapshots": snapshots, "refs": {}})
4646
table_v2.catalog = MagicMock()
@@ -61,7 +61,7 @@ def test_retain_last_n_snapshots(table_v2: Table) -> None:
6161
finally:
6262
# Restore original catalog and cleanup
6363
table_v2.catalog = original_catalog
64-
if hasattr(original_catalog, '_connection') and original_catalog._connection is not None:
64+
if hasattr(original_catalog, "_connection") and original_catalog._connection is not None:
6565
try:
6666
original_catalog._connection.close()
6767
except Exception:
@@ -78,10 +78,10 @@ def test_min_snapshots_to_keep(table_v2: Table) -> None:
7878
(5, 5000),
7979
]
8080
snapshots = _make_snapshots(ids_and_ts)
81-
81+
8282
# Save original catalog for cleanup
8383
original_catalog = table_v2.catalog
84-
84+
8585
try:
8686
table_v2.metadata = table_v2.metadata.model_copy(update={"snapshots": snapshots, "refs": {}})
8787
table_v2.catalog = MagicMock()
@@ -101,7 +101,7 @@ def test_min_snapshots_to_keep(table_v2: Table) -> None:
101101
finally:
102102
# Restore original catalog and cleanup
103103
table_v2.catalog = original_catalog
104-
if hasattr(original_catalog, '_connection') and original_catalog._connection is not None:
104+
if hasattr(original_catalog, "_connection") and original_catalog._connection is not None:
105105
try:
106106
original_catalog._connection.close()
107107
except Exception:
@@ -336,7 +336,7 @@ def test_expire_snapshots_by_ids(table_v2: Table) -> None:
336336
finally:
337337
# Restore original catalog and cleanup any connections
338338
table_v2.catalog = original_catalog
339-
if hasattr(original_catalog, '_connection') and original_catalog._connection is not None:
339+
if hasattr(original_catalog, "_connection") and original_catalog._connection is not None:
340340
try:
341341
original_catalog._connection.close()
342342
except Exception:
@@ -354,13 +354,13 @@ def test_expire_snapshots_with_table_property_defaults(table_v2: Table) -> None:
354354
(5, 5000), # Should be kept (newer than max age)
355355
]
356356
snapshots = _make_snapshots(ids_and_ts)
357-
357+
358358
# Set table properties
359359
properties = {
360360
"history.expire.max-snapshot-age-ms": "4500", # Keep snapshots newer than this
361-
"history.expire.min-snapshots-to-keep": "3", # Always keep at least 3 snapshots
361+
"history.expire.min-snapshots-to-keep": "3", # Always keep at least 3 snapshots
362362
}
363-
363+
364364
table_v2.metadata = table_v2.metadata.model_copy(
365365
update={
366366
"snapshots": snapshots,
@@ -399,13 +399,13 @@ def test_explicit_parameters_override_table_properties(table_v2: Table) -> None:
399399
(5, 5000), # Will be kept (min snapshots)
400400
]
401401
snapshots = _make_snapshots(ids_and_ts)
402-
402+
403403
# Set table properties that are more aggressive than what we'll use
404404
properties = {
405405
"history.expire.max-snapshot-age-ms": "1500", # Would expire more snapshots
406-
"history.expire.min-snapshots-to-keep": "2", # Would keep fewer snapshots
406+
"history.expire.min-snapshots-to-keep": "2", # Would keep fewer snapshots
407407
}
408-
408+
409409
table_v2.metadata = table_v2.metadata.model_copy(
410410
update={
411411
"snapshots": snapshots,
@@ -427,7 +427,7 @@ def test_explicit_parameters_override_table_properties(table_v2: Table) -> None:
427427
# Call expire with explicit parameters that should override the properties
428428
table_v2.maintenance.expire_snapshots_with_retention_policy(
429429
timestamp_ms=1500, # Only expire snapshots older than this
430-
min_snapshots_to_keep=4 # Keep at least 4 snapshots (overrides property of 2)
430+
min_snapshots_to_keep=4, # Keep at least 4 snapshots (overrides property of 2)
431431
)
432432

433433
table_v2.catalog.commit_table.assert_called_once()
@@ -447,7 +447,7 @@ def test_expire_snapshots_no_properties_no_parameters(table_v2: Table) -> None:
447447
(5, 5000),
448448
]
449449
snapshots = _make_snapshots(ids_and_ts)
450-
450+
451451
table_v2.metadata = table_v2.metadata.model_copy(
452452
update={
453453
"snapshots": snapshots,

0 commit comments

Comments
 (0)