Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit a8d1efb

Browse files
dlawinerezsh
authored andcommitted
lint
1 parent 9565b99 commit a8d1efb

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

data_diff/diff_tables.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def _run_in_background(self, *funcs):
7878
for f in futures:
7979
f.result()
8080

81+
8182
@dataclass
8283
class DiffStats:
8384
diff_by_sign: dict[str, int]
@@ -86,6 +87,7 @@ class DiffStats:
8687
unchanged: int
8788
diff_percent: float
8889

90+
8991
@dataclass
9092
class DiffResultWrapper:
9193
diff: iter # DiffResult
@@ -145,18 +147,19 @@ def get_stats_dict(self):
145147

146148
diff_stats = self._get_stats()
147149
json_output = {
148-
"rows_A": diff_stats.table1_count,
149-
"rows_B": diff_stats.table2_count,
150-
"exclusive_A": diff_stats.diff_by_sign["-"],
151-
"exclusive_B": diff_stats.diff_by_sign["+"],
152-
"updated": diff_stats.diff_by_sign["!"],
153-
"unchanged": diff_stats.unchanged,
154-
"total": sum(diff_stats.diff_by_sign.values()),
155-
"stats": self.stats,
156-
}
150+
"rows_A": diff_stats.table1_count,
151+
"rows_B": diff_stats.table2_count,
152+
"exclusive_A": diff_stats.diff_by_sign["-"],
153+
"exclusive_B": diff_stats.diff_by_sign["+"],
154+
"updated": diff_stats.diff_by_sign["!"],
155+
"unchanged": diff_stats.unchanged,
156+
"total": sum(diff_stats.diff_by_sign.values()),
157+
"stats": self.stats,
158+
}
157159

158160
return json_output
159161

162+
160163
class TableDiffer(ThreadBase, ABC):
161164
bisection_factor = 32
162165
stats: dict = {}

tests/test_api.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,18 @@ def test_api_get_stats_string(self):
8989

9090
t1.database.close()
9191
t2.database.close()
92-
92+
9393
def test_api_get_stats_dict(self):
94-
expected_dict = {'rows_A': 5, 'rows_B': 4, 'exclusive_A': 1, 'exclusive_B': 0, 'updated': 0, 'unchanged': 4, 'total': 1, 'stats': {'rows_downloaded': 5}}
94+
expected_dict = {
95+
"rows_A": 5,
96+
"rows_B": 4,
97+
"exclusive_A": 1,
98+
"exclusive_B": 0,
99+
"updated": 0,
100+
"unchanged": 4,
101+
"total": 1,
102+
"stats": {"rows_downloaded": 5},
103+
}
95104
t1 = connect_to_table(TEST_MYSQL_CONN_STRING, self.table_src_name)
96105
t2 = connect_to_table(TEST_MYSQL_CONN_STRING, self.table_dst_name)
97106
diff = diff_tables(t1, t2)

tests/test_cli.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ def tearDown(self) -> None:
6868
return super().tearDown()
6969

7070
def test_basic(self):
71-
diff = run_datadiff_cli(TEST_MYSQL_CONN_STRING, self.table_src_name, TEST_MYSQL_CONN_STRING, self.table_dst_name)
71+
diff = run_datadiff_cli(
72+
TEST_MYSQL_CONN_STRING, self.table_src_name, TEST_MYSQL_CONN_STRING, self.table_dst_name
73+
)
7274
assert len(diff) == 1
7375

7476
def test_options(self):
@@ -95,13 +97,13 @@ def test_stats(self):
9597
TEST_MYSQL_CONN_STRING, self.table_src_name, TEST_MYSQL_CONN_STRING, self.table_dst_name, "-s"
9698
)
9799
assert len(diff_output) == 11
98-
100+
99101
def test_stats_json(self):
100102
diff_output = run_datadiff_cli(
101103
TEST_MYSQL_CONN_STRING, self.table_src_name, TEST_MYSQL_CONN_STRING, self.table_dst_name, "-s", "--json"
102104
)
103105
assert len(diff_output) == 2
104-
106+
105107
def test_stats_no_diff(self):
106108
diff_output = run_datadiff_cli(
107109
TEST_MYSQL_CONN_STRING, self.table_src_name, TEST_MYSQL_CONN_STRING, self.table_src_name, "-s"

0 commit comments

Comments
 (0)