Skip to content

Commit 406ef77

Browse files
committed
sty: run ruff format
1 parent 48ab265 commit 406ef77

File tree

9 files changed

+35
-43
lines changed

9 files changed

+35
-43
lines changed

templateflow/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# https://www.nipreps.org/community/licensing/
2222
#
2323
"""TemplateFlow is the Zone of Templates."""
24+
2425
from datetime import datetime as _dt
2526
from datetime import timezone as _tz
2627

@@ -30,6 +31,7 @@
3031
from ._version import __version__
3132
except ModuleNotFoundError:
3233
from importlib.metadata import PackageNotFoundError, version
34+
3335
try:
3436
__version__ = version(__packagename__)
3537
except PackageNotFoundError:

templateflow/_loader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
2525
.. autoclass:: Loader
2626
"""
27+
2728
from __future__ import annotations
2829

2930
import atexit

templateflow/api.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# https://www.nipreps.org/community/licensing/
2222
#
2323
"""TemplateFlow's Python Client."""
24+
2425
import sys
2526
from json import loads
2627
from pathlib import Path
@@ -35,9 +36,7 @@
3536
requires_layout,
3637
)
3738

38-
_layout_dir = tuple(
39-
item for item in dir(TF_LAYOUT) if item.startswith('get_')
40-
)
39+
_layout_dir = tuple(item for item in dir(TF_LAYOUT) if item.startswith('get_'))
4140

4241

4342
@requires_layout
@@ -92,10 +91,9 @@ def ls(template, **kwargs):
9291
kwargs['extension'] = _normalize_ext(kwargs['extension'])
9392

9493
return [
95-
Path(p) for p in TF_LAYOUT.get(
96-
template=Query.ANY if template is None else template,
97-
return_type='file',
98-
**kwargs
94+
Path(p)
95+
for p in TF_LAYOUT.get(
96+
template=Query.ANY if template is None else template, return_type='file', **kwargs
9997
)
10098
]
10199

templateflow/cli.py

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# https://www.nipreps.org/community/licensing/
2222
#
2323
"""The TemplateFlow Python Client command-line interface (CLI)."""
24+
2425
from __future__ import annotations
2526

2627
import json
@@ -31,20 +32,20 @@
3132

3233
from templateflow import __package__, api
3334
from templateflow._loader import Loader as _Loader
34-
from templateflow.conf import TF_HOME, TF_USE_DATALAD, TF_AUTOUPDATE
35+
from templateflow.conf import TF_AUTOUPDATE, TF_HOME, TF_USE_DATALAD
3536

3637
load_data = _Loader(__package__)
3738

3839
ENTITY_SHORTHANDS = {
3940
# 'template': ('--tpl', '-t'),
40-
'resolution': ('--res', ),
41-
'density': ('--den', ),
42-
'atlas': ('-a', ),
43-
'suffix': ('-s', ),
41+
'resolution': ('--res',),
42+
'density': ('--den',),
43+
'atlas': ('-a',),
44+
'suffix': ('-s',),
4445
'desc': ('-d', '--description'),
4546
'extension': ('--ext', '-x'),
46-
'label': ('-l', ),
47-
'segmentation': ('--seg', ),
47+
'label': ('-l',),
48+
'segmentation': ('--seg',),
4849
}
4950
ENTITY_EXCLUDE = {'template', 'description'}
5051
TEMPLATE_LIST = api.get_templates()
@@ -57,16 +58,12 @@ def _nulls(s):
5758
def entity_opts():
5859
"""Attaches all entities as options to the command."""
5960

60-
entities = json.loads(
61-
Path(load_data('conf/config.json')).read_text()
62-
)['entities']
61+
entities = json.loads(Path(load_data('conf/config.json')).read_text())['entities']
6362

6463
args = [
65-
(
66-
f"--{e['name']}",
67-
*ENTITY_SHORTHANDS.get(e['name'], ())
68-
)
69-
for e in entities if e['name'] not in ENTITY_EXCLUDE
64+
(f"--{e['name']}", *ENTITY_SHORTHANDS.get(e['name'], ()))
65+
for e in entities
66+
if e['name'] not in ENTITY_EXCLUDE
7067
]
7168

7269
def decorator(f: FC) -> FC:
@@ -135,9 +132,7 @@ def update(local, overwrite):
135132
def ls(template, **kwargs):
136133
"""List the assets corresponding to template and optional filters."""
137134
entities = {k: _nulls(v) for k, v in kwargs.items() if v != ''}
138-
click.echo(
139-
'\n'.join(f'{match}' for match in api.ls(template, **entities))
140-
)
135+
click.echo('\n'.join(f'{match}' for match in api.ls(template, **entities)))
141136

142137

143138
@main.command()
@@ -146,9 +141,7 @@ def ls(template, **kwargs):
146141
def get(template, **kwargs):
147142
"""Fetch the assets corresponding to template and optional filters."""
148143
entities = {k: _nulls(v) for k, v in kwargs.items() if v != ''}
149-
click.echo(
150-
'\n'.join(f'{match}' for match in api.get(template, **entities))
151-
)
144+
click.echo('\n'.join(f'{match}' for match in api.get(template, **entities)))
152145

153146

154147
if __name__ == '__main__':

templateflow/conf/_s3.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# https://www.nipreps.org/community/licensing/
2222
#
2323
"""Tooling to handle S3 downloads."""
24+
2425
from pathlib import Path
2526
from tempfile import mkstemp
2627

@@ -93,10 +94,7 @@ def _update_skeleton(skel_file, dest, overwrite=True, silent=False):
9394

9495
if newfiles:
9596
if not silent:
96-
print(
97-
'Updating TEMPLATEFLOW_HOME using S3. Adding:\n%s'
98-
% '\n'.join(newfiles)
99-
)
97+
print('Updating TEMPLATEFLOW_HOME using S3. Adding:\n%s' % '\n'.join(newfiles))
10098
for fl in newfiles:
10199
localpath = dest / fl
102100
if localpath.exists():

templateflow/conf/bids.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# https://www.nipreps.org/community/licensing/
2222
#
2323
"""Extending pyBIDS for querying TemplateFlow."""
24+
2425
from bids.layout import BIDSLayout, add_config_paths
2526

2627
from templateflow.conf import load_data
@@ -34,7 +35,5 @@ def __repr__(self):
3435
s = """\
3536
TemplateFlow Layout
3637
- Home: {}
37-
- Templates: {}.""".format(
38-
self.root, ', '.join(sorted(self.get_templates()))
39-
)
38+
- Templates: {}.""".format(self.root, ', '.join(sorted(self.get_templates())))
4039
return s

templateflow/tests/test_api.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,7 @@ def assert_same(self, other):
154154
journal={Cerebral Cortex}
155155
}"""
156156

157-
fslr_lbib = (
158-
'https://github.com/Washington-University/HCPpipelines/tree/master/global/templates'
159-
)
157+
fslr_lbib = 'https://github.com/Washington-University/HCPpipelines/tree/master/global/templates'
160158

161159
fsaverage_fbib = """\
162160
@article{Fischl_1999,
@@ -181,9 +179,7 @@ def assert_same(self, other):
181179
('fsLR', fslr_urls, fslr_fbib, fslr_lbib),
182180
(
183181
'fsaverage',
184-
[
185-
'https://doi.org/10.1002/(sici)1097-0193(1999)8:4%3C272::aid-hbm10%3E3.0.co;2-4'
186-
],
182+
['https://doi.org/10.1002/(sici)1097-0193(1999)8:4%3C272::aid-hbm10%3E3.0.co;2-4'],
187183
fsaverage_fbib,
188184
None,
189185
),

templateflow/tests/test_s3.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
# https://www.nipreps.org/community/licensing/
2222
#
2323
"""Check S3-type repo tooling."""
24+
25+
from importlib import reload
2426
from pathlib import Path
27+
2528
import requests
26-
from importlib import reload
2729

2830
from templateflow import conf as tfc
2931

@@ -46,7 +48,9 @@ def test_get_skel_file(tmp_path, monkeypatch):
4648
assert Path(new_skel).stat().st_size > 0
4749

4850
latest_md5 = (
49-
requests.get(tfc._s3.TF_SKEL_URL(release='master', ext='md5', allow_redirects=True), timeout=10)
51+
requests.get(
52+
tfc._s3.TF_SKEL_URL(release='master', ext='md5', allow_redirects=True), timeout=10
53+
)
5054
.content.decode()
5155
.split()[0]
5256
)

templateflow/tests/test_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# https://www.nipreps.org/community/licensing/
2222
#
2323
"""Test version retrieval."""
24+
2425
import sys
2526
from importlib import reload
2627
from importlib.metadata import PackageNotFoundError

0 commit comments

Comments
 (0)