Skip to content

Commit f88e9d2

Browse files
committed
Restructure cursor call to satisfy Black 26 chained-call wrap rule
1 parent 33f03ac commit f88e9d2

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

amiadapters/storage/snowflake.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,16 +1005,18 @@ def calculate_end_of_backfill_range(
10051005
# heuristic that got stuck on orgs whose leading edge had
10061006
# below-threshold per-day read volume (legitimate ramp-up at the
10071007
# start of vendor data).
1008-
result = conn.cursor().execute(
1008+
cursor = conn.cursor()
1009+
cursor.execute(
10091010
"""
10101011
SELECT MIN(flowtime) FROM readings
10111012
WHERE org_id = ? AND flowtime > ? AND flowtime < ?
10121013
""",
10131014
(org_id, min_date, max_date),
1014-
).fetchall()
1015-
if not result or result[0][0] is None:
1015+
)
1016+
row = cursor.fetchone()
1017+
if row is None or row[0] is None:
10161018
return max_date
1017-
return result[0][0]
1019+
return row[0]
10181020

10191021

10201022
class SnowflakeMetersUniqueByDeviceIdCheck(BaseAMIDataQualityCheck):

test/amiadapters/storage/test_snowflake.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def test_verify_no_duplicate_reads_and_return_oldest_flowtime_finds_oldest_flowt
475475

476476
def test_calculate_end_of_backfill_range__returns_min_flowtime(self):
477477
expected_min = datetime.datetime(2024, 11, 29, 19, 0, tzinfo=pytz.UTC)
478-
self.mock_cursor.execute.return_value.fetchall.return_value = [(expected_min,)]
478+
self.mock_cursor.fetchone.return_value = (expected_min,)
479479

480480
result = self.snowflake_sink.calculate_end_of_backfill_range(
481481
"some_org",
@@ -487,7 +487,7 @@ def test_calculate_end_of_backfill_range__returns_min_flowtime(self):
487487

488488
def test_calculate_end_of_backfill_range__returns_max_date_when_no_readings(self):
489489
max_date = datetime.datetime(2026, 4, 23)
490-
self.mock_cursor.execute.return_value.fetchall.return_value = [(None,)]
490+
self.mock_cursor.fetchone.return_value = (None,)
491491

492492
result = self.snowflake_sink.calculate_end_of_backfill_range(
493493
"some_org",

0 commit comments

Comments
 (0)