Skip to content

Commit db1cff7

Browse files
committed
Upgrade Black to 22.1.0
1 parent e974ec3 commit db1cff7

7 files changed

Lines changed: 52 additions & 76 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/ambv/black
3-
rev: '21.12b0'
3+
rev: 22.1.0
44
hooks:
55
- id: black
66
language_version: python3.8

splitgraph/core/output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def pretty_size(size: Union[int, float]) -> str:
1212
:param size: Size in bytes
1313
"""
1414
size = float(size)
15-
power = 2 ** 10
15+
power = 2**10
1616
base = 0
1717
while size > power:
1818
size /= power

splitgraph/hooks/data_source/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def _load_plugin_from_dir(
9797
spec.loader.exec_module(module) # type:ignore
9898
if hasattr(module, "__plugin__"):
9999
logging.debug("Loading %s", plugin_file)
100-
data_source = module.__plugin__ # type: ignore
100+
data_source = module.__plugin__
101101
if not issubclass(data_source, DataSource):
102102
logging.warning(
103103
"Data source %s in %s isn't an instance of DataSource. Ignoring.",

test/splitgraph/commands/test_commit_diff.py

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,12 @@ def test_commit_chunking(local_engine_empty):
166166
)
167167

168168
# Check object contents
169-
assert (
170-
local_engine_empty.run_sql(
171-
SQL("SELECT key FROM {}.{} ORDER BY key").format(
172-
Identifier(SPLITGRAPH_META_SCHEMA), Identifier(obj)
173-
),
174-
return_shape=ResultShape.MANY_ONE,
175-
)
176-
== list(range(min_key, max_key + 1))
177-
)
169+
assert local_engine_empty.run_sql(
170+
SQL("SELECT key FROM {}.{} ORDER BY key").format(
171+
Identifier(SPLITGRAPH_META_SCHEMA), Identifier(obj)
172+
),
173+
return_shape=ResultShape.MANY_ONE,
174+
) == list(range(min_key, max_key + 1))
178175

179176
# Test checkout progress reporting
180177
with mock.patch("splitgraph.core.table._PROGRESS_EVERY", 1):
@@ -202,15 +199,12 @@ def test_commit_chunking_order(local_engine_empty):
202199
objects = head.get_table("test").objects
203200
# When queried without an order, we should get the natural order
204201
# of values in the chunk (they were inserted in the same order as the key in this case)
205-
assert (
206-
local_engine_empty.run_sql(
207-
SQL("SELECT key FROM {}.{}").format(
208-
Identifier(SPLITGRAPH_META_SCHEMA), Identifier(objects[0])
209-
),
210-
return_shape=ResultShape.MANY_ONE,
211-
)
212-
== list(range(1, 6))
213-
)
202+
assert local_engine_empty.run_sql(
203+
SQL("SELECT key FROM {}.{}").format(
204+
Identifier(SPLITGRAPH_META_SCHEMA), Identifier(objects[0])
205+
),
206+
return_shape=ResultShape.MANY_ONE,
207+
) == list(range(1, 6))
214208

215209
# Commit again overwriting objects and changing the sort order
216210
head = OUTPUT.commit(
@@ -222,26 +216,20 @@ def test_commit_chunking_order(local_engine_empty):
222216
for i, obj in enumerate(objects):
223217
min_key = i * 5 + 1
224218
max_key = min(i * 5 + 5, 11)
225-
assert (
226-
local_engine_empty.run_sql(
227-
SQL("SELECT key FROM {}.{} ORDER BY key").format(
228-
Identifier(SPLITGRAPH_META_SCHEMA), Identifier(obj)
229-
),
230-
return_shape=ResultShape.MANY_ONE,
231-
)
232-
== list(range(min_key, max_key + 1))
233-
)
219+
assert local_engine_empty.run_sql(
220+
SQL("SELECT key FROM {}.{} ORDER BY key").format(
221+
Identifier(SPLITGRAPH_META_SCHEMA), Identifier(obj)
222+
),
223+
return_shape=ResultShape.MANY_ONE,
224+
) == list(range(min_key, max_key + 1))
234225

235226
# This time, the natural order is by value_1 and so rows go backwards.
236-
assert (
237-
local_engine_empty.run_sql(
238-
SQL("SELECT key FROM {}.{}").format(
239-
Identifier(SPLITGRAPH_META_SCHEMA), Identifier(obj)
240-
),
241-
return_shape=ResultShape.MANY_ONE,
242-
)
243-
== list(range(max_key, min_key - 1, -1))
244-
)
227+
assert local_engine_empty.run_sql(
228+
SQL("SELECT key FROM {}.{}").format(
229+
Identifier(SPLITGRAPH_META_SCHEMA), Identifier(obj)
230+
),
231+
return_shape=ResultShape.MANY_ONE,
232+
) == list(range(max_key, min_key - 1, -1))
245233

246234

247235
def test_commit_diff_splitting(local_engine_empty):

test/splitgraph/commands/test_push_pull.py

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,13 @@ def test_push(local_engine_empty, pg_repo_remote):
272272
head_3 = PG_MNT.commit(snap_only=True, in_fragment_order={"fruits": ["name"]}, overwrite=True)
273273
assert head_3.get_table("fruits").objects == head_2.get_table("fruits").objects
274274

275-
assert (
276-
PG_MNT.run_sql(
277-
SQL("SELECT fruit_id FROM {}.{}").format(
278-
Identifier(SPLITGRAPH_META_SCHEMA),
279-
Identifier(head_2.get_table("fruits").objects[0]),
280-
),
281-
return_shape=ResultShape.MANY_ONE,
282-
)
283-
== [1, 3, 2]
284-
)
275+
assert PG_MNT.run_sql(
276+
SQL("SELECT fruit_id FROM {}.{}").format(
277+
Identifier(SPLITGRAPH_META_SCHEMA),
278+
Identifier(head_2.get_table("fruits").objects[0]),
279+
),
280+
return_shape=ResultShape.MANY_ONE,
281+
) == [1, 3, 2]
285282

286283
# Force push overwriting object meta and the actual object
287284
PG_MNT.push(
@@ -291,16 +288,13 @@ def test_push(local_engine_empty, pg_repo_remote):
291288
reupload_objects=True,
292289
)
293290

294-
assert (
295-
pg_repo_remote.run_sql(
296-
SQL("SELECT fruit_id FROM {}.{}").format(
297-
Identifier(SPLITGRAPH_META_SCHEMA),
298-
Identifier(head_2.get_table("fruits").objects[0]),
299-
),
300-
return_shape=ResultShape.MANY_ONE,
301-
)
302-
== [1, 3, 2]
303-
)
291+
assert pg_repo_remote.run_sql(
292+
SQL("SELECT fruit_id FROM {}.{}").format(
293+
Identifier(SPLITGRAPH_META_SCHEMA),
294+
Identifier(head_2.get_table("fruits").objects[0]),
295+
),
296+
return_shape=ResultShape.MANY_ONE,
297+
) == [1, 3, 2]
304298
# apple, mayonnaise, orange (alphabetical order since we sorted on fruit name)
305299

306300

test/splitgraph/ingestion/test_csv.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -437,13 +437,10 @@ def test_csv_data_source_s3(local_engine_empty):
437437
assert local_engine_empty.run_sql('SELECT COUNT(1) FROM temp_data."fruits.csv"') == [(4,)]
438438

439439
# Test NULL "inference" for numbers
440-
assert (
441-
local_engine_empty.run_sql(
442-
'SELECT number FROM temp_data."fruits.csv"',
443-
return_shape=ResultShape.MANY_ONE,
444-
)
445-
== [1, 2, None, 4]
446-
)
440+
assert local_engine_empty.run_sql(
441+
'SELECT number FROM temp_data."fruits.csv"',
442+
return_shape=ResultShape.MANY_ONE,
443+
) == [1, 2, None, 4]
447444

448445
assert local_engine_empty.run_sql(
449446
'SELECT COUNT(1) FROM temp_data."rdu-weather-history.csv"'

test/splitgraph/test_engine.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,16 +265,13 @@ def test_client_query_batch_chunk_whole():
265265

266266
# Return list of singletons
267267
engine.run_sql.side_effect = (["result_1", "result_2"], ["result_3"])
268-
assert (
269-
PsycopgEngine.run_chunked_sql(
270-
engine,
271-
query,
272-
args,
273-
return_shape=ResultShape.MANY_ONE,
274-
chunk_size=2,
275-
)
276-
== ["result_1", "result_2", "result_3"]
277-
)
268+
assert PsycopgEngine.run_chunked_sql(
269+
engine,
270+
query,
271+
args,
272+
return_shape=ResultShape.MANY_ONE,
273+
chunk_size=2,
274+
) == ["result_1", "result_2", "result_3"]
278275
assert engine.run_sql.mock_calls == [
279276
call(query, args[:2], ResultShape.MANY_ONE),
280277
call(query, args[2:], ResultShape.MANY_ONE),

0 commit comments

Comments
 (0)