Skip to content

Commit 4f0721e

Browse files
linglpLingling PengLingling Peng
authored
[SYNPY-1798]: updated black to 26.3.1 and reran pre-commit (#1341)
* update black to 26.3.1 and rerun pre-commit * update the tutorial line --------- Co-authored-by: Lingling Peng <lpeng@w290.local> Co-authored-by: Lingling Peng <lpeng@Mac.SageCorpWiFi>
1 parent 693d01b commit 4f0721e

83 files changed

Lines changed: 3018 additions & 2340 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ repos:
3030
name: isort (python)
3131

3232
- repo: https://github.com/psf/black
33-
rev: 23.3.0
33+
rev: 26.3.1
3434
hooks:
3535
- id: black
3636
language_version: python3

Pipfile.lock

Lines changed: 146 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/scripts/object_orientated_programming_poc/synapse_project.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
1111
All steps also include setting a number of annotations for the objects.
1212
"""
13+
1314
import os
1415
import uuid
1516
from datetime import datetime, timedelta, timezone

docs/tutorials/python/tutorial_scripts/upload_data_in_bulk.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,19 @@
6666

6767
# After finding the row we want to update let's go ahead and add a relationship to
6868
# another file in our manifest. This allows us to say "We used 'this' file in some way".
69-
df.loc[
70-
row_index, "used"
71-
] = f"{DIRECTORY_FOR_MY_PROJECT}/single_cell_RNAseq_batch_1/SRR12345678_R1.fastq.gz"
69+
df.loc[row_index, "used"] = (
70+
f"{DIRECTORY_FOR_MY_PROJECT}/single_cell_RNAseq_batch_1/SRR12345678_R1.fastq.gz"
71+
)
7272

7373
# Let's also link to the pipeline that we ran in order to produce these results. In a
7474
# real scenario you may want to link to a specific run of the tool where the results
7575
# were produced.
7676
df.loc[row_index, "executed"] = "https://nf-co.re/rnaseq/3.14.0"
7777

7878
# Let's also add a description for this Activity/Provenance
79-
df.loc[
80-
row_index, "activityDescription"
81-
] = "Experiment results created as a result of the linked data while running the pipeline."
79+
df.loc[row_index, "activityDescription"] = (
80+
"Experiment results created as a result of the linked data while running the pipeline."
81+
)
8282

8383
# Write the DataFrame back to the manifest file
8484
df.to_csv(PATH_TO_MANIFEST_FILE, sep="\t", index=False)

docs/tutorials/python/tutorial_scripts/wiki.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
7. Delete wiki pages
1313
1414
"""
15+
1516
import os
1617

1718
from synapseclient import Synapse

docs/tutorials/python/wiki.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ In this tutorial you will:
3131
## 1. Create a Wiki page
3232
### Initial setup
3333
```python
34-
{!docs/tutorials/python/tutorial_scripts/wiki.py!lines=15-31}
34+
{!docs/tutorials/python/tutorial_scripts/wiki.py!lines=16-31}
3535
```
3636
A Wiki page requires an owner object, a title, and markdown. Here is an example to create a new root Wiki page for your project with plain text markdown:
3737
```python

synapseclient/activity.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ def used(
223223

224224
resource = target
225225
if "concreteType" not in resource:
226-
resource[
227-
"concreteType"
228-
] = "org.sagebionetworks.repo.model.provenance.UsedEntity"
226+
resource["concreteType"] = (
227+
"org.sagebionetworks.repo.model.provenance.UsedEntity"
228+
)
229229

230230
# -- Used URL
231231
elif is_used_url(target):
@@ -234,9 +234,9 @@ def used(
234234

235235
resource = target
236236
if "concreteType" not in resource:
237-
resource[
238-
"concreteType"
239-
] = "org.sagebionetworks.repo.model.provenance.UsedURL"
237+
resource["concreteType"] = (
238+
"org.sagebionetworks.repo.model.provenance.UsedURL"
239+
)
240240

241241
# -- Synapse Entity
242242
elif is_synapse_entity(target):

synapseclient/api/docker_commit_services.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""This module is responsible for exposing the services defined at:
22
<https://rest-docs.synapse.org/rest/#org.sagebionetworks.repo.web.controller.DockerCommitController>
33
"""
4+
45
from typing import TYPE_CHECKING, Optional
56

67
if TYPE_CHECKING:

synapseclient/api/file_services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ async def post_external_filehandle(
269269
"contentSize": file_size,
270270
}
271271
if mimetype is None:
272-
(mimetype, _) = mimetypes.guess_type(external_url, strict=False)
272+
mimetype, _ = mimetypes.guess_type(external_url, strict=False)
273273
if mimetype is not None:
274274
file_handle["contentType"] = mimetype
275275
return await client.rest_post_async(

synapseclient/client.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
The `Synapse` object encapsulates a connection to the Synapse service and is used for building projects, uploading and
33
retrieving data, and recording provenance of data analysis.
44
"""
5+
56
import asyncio
67
import collections
78
import collections.abc
@@ -607,9 +608,7 @@ def _init_logger(self):
607608
logger_name = (
608609
SILENT_LOGGER_NAME
609610
if self.silent
610-
else DEBUG_LOGGER_NAME
611-
if self.debug
612-
else DEFAULT_LOGGER_NAME
611+
else DEBUG_LOGGER_NAME if self.debug else DEFAULT_LOGGER_NAME
613612
)
614613
self.logger = logging.getLogger(logger_name)
615614
logging.getLogger("py.warnings").handlers = self.logger.handlers
@@ -2672,9 +2671,11 @@ async def main():
26722671
fileHandle = await upload_file_handle_async(
26732672
self,
26742673
parent_id_for_upload,
2675-
local_state["path"]
2676-
if (synapseStore or local_state_fh.get("externalURL") is None)
2677-
else local_state_fh.get("externalURL"),
2674+
(
2675+
local_state["path"]
2676+
if (synapseStore or local_state_fh.get("externalURL") is None)
2677+
else local_state_fh.get("externalURL")
2678+
),
26782679
synapse_store=synapseStore,
26792680
md5=local_file_md5_hex or local_state_fh.get("contentMd5"),
26802681
file_size=local_state_fh.get("contentSize"),
@@ -3243,9 +3244,10 @@ def get_download_list(self, downloadLocation: str = None) -> str:
32433244
dl_list_path = self.get_download_list_manifest()
32443245
downloaded_files = []
32453246
new_manifest_path = f"manifest_{time.time_ns()}.csv"
3246-
with open(dl_list_path) as manifest_f, open(
3247-
new_manifest_path, "w"
3248-
) as write_obj:
3247+
with (
3248+
open(dl_list_path) as manifest_f,
3249+
open(new_manifest_path, "w") as write_obj,
3250+
):
32493251
reader = csv.DictReader(manifest_f)
32503252
columns = reader.fieldnames
32513253
columns.extend(["path", "error"])
@@ -4925,9 +4927,11 @@ def _convertProvenanceList(self, usedList: list, limitSearch: str = None) -> lis
49254927
if usedList is None:
49264928
return None
49274929
usedList = [
4928-
self.get(target, limitSearch=limitSearch)
4929-
if (os.path.isfile(target) if isinstance(target, str) else False)
4930-
else target
4930+
(
4931+
self.get(target, limitSearch=limitSearch)
4932+
if (os.path.isfile(target) if isinstance(target, str) else False)
4933+
else target
4934+
)
49314935
for target in usedList
49324936
]
49334937
return usedList
@@ -5468,7 +5472,7 @@ def _createExternalFileHandle(
54685472
"contentSize": fileSize,
54695473
}
54705474
if mimetype is None:
5471-
(mimetype, enc) = mimetypes.guess_type(externalURL, strict=False)
5475+
mimetype, enc = mimetypes.guess_type(externalURL, strict=False)
54725476
if mimetype is not None:
54735477
fileHandle["contentType"] = mimetype
54745478
return self.restPOST(
@@ -5893,16 +5897,16 @@ async def create_s3_storage_location_async(
58935897
}
58945898

58955899
if bucket_name:
5896-
storage_location_kwargs[
5897-
"concreteType"
5898-
] = concrete_types.EXTERNAL_S3_STORAGE_LOCATION_SETTING
5900+
storage_location_kwargs["concreteType"] = (
5901+
concrete_types.EXTERNAL_S3_STORAGE_LOCATION_SETTING
5902+
)
58995903
storage_location_kwargs["bucket"] = bucket_name
59005904
if base_key:
59015905
storage_location_kwargs["baseKey"] = base_key
59025906
else:
5903-
storage_location_kwargs[
5904-
"concreteType"
5905-
] = concrete_types.SYNAPSE_S3_STORAGE_LOCATION_SETTING
5907+
storage_location_kwargs["concreteType"] = (
5908+
concrete_types.SYNAPSE_S3_STORAGE_LOCATION_SETTING
5909+
)
59065910

59075911
storage_location_setting = self.restPOST(
59085912
"/storageLocation", json.dumps(storage_location_kwargs)

0 commit comments

Comments
 (0)