Skip to content

Commit 36e57a4

Browse files
committed
reformat scripts
1 parent e411013 commit 36e57a4

7 files changed

Lines changed: 197 additions & 120 deletions

File tree

docs/tutorials/python/tutorial_scripts/migration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
"""Tutorial code for Index and migrate files to the new storage location
2-
"""
1+
"""Tutorial code for Index and migrate files to the new storage location"""
2+
33
# --8<-- [start:setup]
44
import synapseclient
55
from synapseclient.models import Folder, Project

docs/tutorials/python/tutorial_scripts/proxy_storage_location.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Tutorial code for creating a Proxy storage location and uploading a file via ProxyFileHandle."""
2+
23
# --8<-- [start:setup]
34
import asyncio
45
import hashlib

docs/tutorials/python/tutorial_scripts/storage_location.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Tutorial code for the Storage Location and project settings.
33
"""
4+
45
# --8<-- [start:setup]
56
import synapseclient
67
from synapseclient.models import Folder, Project, StorageLocation, StorageLocationType

synapseclient/models/services/migration.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,7 @@ def _escape_column_name(column: Union[str, collections.abc.Mapping]) -> str:
148148
col_name = (
149149
column["name"]
150150
if isinstance(column, collections.abc.Mapping)
151-
else column.name
152-
if isinstance(column, Column)
153-
else str(column)
151+
else column.name if isinstance(column, Column) else str(column)
154152
)
155153
escaped_name = col_name.replace('"', '""')
156154
return f'"{escaped_name}"'
@@ -213,8 +211,7 @@ def _ensure_schema(cursor: sqlite3.Cursor) -> None:
213211
# The representation of migratable file handles is flat including both file entities
214212
# and table attached files, so not all columns are applicable to both. row id and col id
215213
# are only used by table attached files.
216-
cursor.execute(
217-
"""
214+
cursor.execute("""
218215
CREATE TABLE IF NOT EXISTS migrations (
219216
id TEXT NOT NULL,
220217
type INTEGER NOT NULL,
@@ -230,8 +227,7 @@ def _ensure_schema(cursor: sqlite3.Cursor) -> None:
230227
file_size INTEGER NULL,
231228
PRIMARY KEY (id, type, row_id, col_id, version)
232229
)
233-
"""
234-
)
230+
""")
235231

236232
# Index the status column for faster status-based lookups
237233
cursor.execute("CREATE INDEX IF NOT EXISTS ix_status ON migrations(status)")

tests/unit/synapseclient/models/async/unit_test_folder_async.py

Lines changed: 102 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -854,11 +854,17 @@ async def test_set_storage_location_creates_new_custom_storage_location(
854854
"""Test that when there is no existing project setting and we set a storage location, a new project setting is created."""
855855
folder = Folder(id=SYN_123)
856856

857-
with patch.object(
858-
ProjectSetting, "get_async", new_callable=AsyncMock, return_value=None
859-
), patch.object(
860-
ProjectSetting, "store_async", autospec=True, return_value=example_setting
861-
) as mocked_store:
857+
with (
858+
patch.object(
859+
ProjectSetting, "get_async", new_callable=AsyncMock, return_value=None
860+
),
861+
patch.object(
862+
ProjectSetting,
863+
"store_async",
864+
autospec=True,
865+
return_value=example_setting,
866+
) as mocked_store,
867+
):
862868
result = await folder.set_storage_location_async(
863869
storage_location_id=self.STORAGE_LOCATION_ID,
864870
synapse_client=self.syn,
@@ -883,14 +889,20 @@ async def test_set_storage_location_updates_existing_setting(
883889
locations=[99999],
884890
)
885891

886-
with patch.object(
887-
ProjectSetting,
888-
"get_async",
889-
new_callable=AsyncMock,
890-
return_value=example_setting,
891-
), patch.object(
892-
ProjectSetting, "store_async", autospec=True, return_value=updated_setting
893-
) as mocked_store:
892+
with (
893+
patch.object(
894+
ProjectSetting,
895+
"get_async",
896+
new_callable=AsyncMock,
897+
return_value=example_setting,
898+
),
899+
patch.object(
900+
ProjectSetting,
901+
"store_async",
902+
autospec=True,
903+
return_value=updated_setting,
904+
) as mocked_store,
905+
):
894906
result = await folder.set_storage_location_async(
895907
storage_location_id=99999,
896908
synapse_client=self.syn,
@@ -919,16 +931,19 @@ async def test_set_storage_location_replaces_all_existing_locations(self) -> Non
919931
locations=[333],
920932
)
921933

922-
with patch.object(
923-
ProjectSetting,
924-
"get_async",
925-
new_callable=AsyncMock,
926-
return_value=existing_setting,
927-
), patch.object(
928-
ProjectSetting,
929-
"store_async",
930-
new_callable=AsyncMock,
931-
return_value=updated_setting,
934+
with (
935+
patch.object(
936+
ProjectSetting,
937+
"get_async",
938+
new_callable=AsyncMock,
939+
return_value=existing_setting,
940+
),
941+
patch.object(
942+
ProjectSetting,
943+
"store_async",
944+
new_callable=AsyncMock,
945+
return_value=updated_setting,
946+
),
932947
):
933948
result = await folder.set_storage_location_async(
934949
storage_location_id=333,
@@ -955,14 +970,20 @@ async def test_set_storage_location_use_default_storage_location_instead(
955970
locations=[DEFAULT_STORAGE_LOCATION_ID],
956971
)
957972

958-
with patch.object(
959-
ProjectSetting,
960-
"get_async",
961-
new_callable=AsyncMock,
962-
return_value=example_setting,
963-
), patch.object(
964-
ProjectSetting, "store_async", autospec=True, return_value=default_setting
965-
) as mocked_store:
973+
with (
974+
patch.object(
975+
ProjectSetting,
976+
"get_async",
977+
new_callable=AsyncMock,
978+
return_value=example_setting,
979+
),
980+
patch.object(
981+
ProjectSetting,
982+
"store_async",
983+
autospec=True,
984+
return_value=default_setting,
985+
) as mocked_store,
986+
):
966987
result = await folder.set_storage_location_async(
967988
synapse_client=self.syn,
968989
)
@@ -988,14 +1009,20 @@ async def test_set_storage_location_uses_default_storage_location_instead_when_s
9881009
locations=[DEFAULT_STORAGE_LOCATION_ID],
9891010
)
9901011

991-
with patch.object(
992-
ProjectSetting,
993-
"get_async",
994-
new_callable=AsyncMock,
995-
return_value=example_setting,
996-
), patch.object(
997-
ProjectSetting, "store_async", autospec=True, return_value=default_setting
998-
) as mocked_store:
1012+
with (
1013+
patch.object(
1014+
ProjectSetting,
1015+
"get_async",
1016+
new_callable=AsyncMock,
1017+
return_value=example_setting,
1018+
),
1019+
patch.object(
1020+
ProjectSetting,
1021+
"store_async",
1022+
autospec=True,
1023+
return_value=default_setting,
1024+
) as mocked_store,
1025+
):
9991026
result = await folder.set_storage_location_async(
10001027
storage_location_id=None,
10011028
synapse_client=self.syn,
@@ -1011,11 +1038,17 @@ async def test_set_storage_location_accepts_list_of_ids(
10111038
"""Test that when storage_location_id is a list of integers, all are stored as-is."""
10121039
folder = Folder(id=SYN_123)
10131040

1014-
with patch.object(
1015-
ProjectSetting, "get_async", new_callable=AsyncMock, return_value=None
1016-
), patch.object(
1017-
ProjectSetting, "store_async", autospec=True, return_value=example_setting
1018-
) as mocked_store:
1041+
with (
1042+
patch.object(
1043+
ProjectSetting, "get_async", new_callable=AsyncMock, return_value=None
1044+
),
1045+
patch.object(
1046+
ProjectSetting,
1047+
"store_async",
1048+
autospec=True,
1049+
return_value=example_setting,
1050+
) as mocked_store,
1051+
):
10191052
await folder.set_storage_location_async(
10201053
storage_location_id=[111, 222, 333],
10211054
synapse_client=self.syn,
@@ -1030,11 +1063,17 @@ async def test_set_storage_location_converts_single_id_to_list(
10301063
"""Test that when storage_location_id is a single integer, it is wrapped in a list."""
10311064
folder = Folder(id=SYN_123)
10321065

1033-
with patch.object(
1034-
ProjectSetting, "get_async", new_callable=AsyncMock, return_value=None
1035-
), patch.object(
1036-
ProjectSetting, "store_async", autospec=True, return_value=example_setting
1037-
) as mocked_store:
1066+
with (
1067+
patch.object(
1068+
ProjectSetting, "get_async", new_callable=AsyncMock, return_value=None
1069+
),
1070+
patch.object(
1071+
ProjectSetting,
1072+
"store_async",
1073+
autospec=True,
1074+
return_value=example_setting,
1075+
) as mocked_store,
1076+
):
10381077
await folder.set_storage_location_async(
10391078
storage_location_id=111,
10401079
synapse_client=self.syn,
@@ -1061,17 +1100,20 @@ async def test_partial_update_locations_via_get_and_store(self) -> None:
10611100
locations=[111, 222, 333],
10621101
)
10631102

1064-
with patch.object(
1065-
ProjectSetting,
1066-
"get_async",
1067-
new_callable=AsyncMock,
1068-
return_value=existing_setting,
1069-
), patch.object(
1070-
ProjectSetting,
1071-
"store_async",
1072-
new_callable=AsyncMock,
1073-
return_value=updated_setting,
1074-
) as mocked_store:
1103+
with (
1104+
patch.object(
1105+
ProjectSetting,
1106+
"get_async",
1107+
new_callable=AsyncMock,
1108+
return_value=existing_setting,
1109+
),
1110+
patch.object(
1111+
ProjectSetting,
1112+
"store_async",
1113+
new_callable=AsyncMock,
1114+
return_value=updated_setting,
1115+
) as mocked_store,
1116+
):
10751117
setting = await folder.get_project_setting_async(
10761118
setting_type="upload",
10771119
synapse_client=self.syn,

0 commit comments

Comments
 (0)