Skip to content

Commit 3dbdbd0

Browse files
authored
Run ruff (#1357)
1 parent f7951b3 commit 3dbdbd0

File tree

20 files changed

+65
-79
lines changed

20 files changed

+65
-79
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@
369369
linkcode_resolve = make_linkcode_resolve(
370370
'xcp_d',
371371
(
372-
'https://github.com/pennlinc/xcp_d/blob/' '{revision}/{package}/{path}#L{lineno}' # noqa: FS003
372+
'https://github.com/pennlinc/xcp_d/blob/{revision}/{package}/{path}#L{lineno}' # noqa: FS003
373373
),
374374
)
375375

xcp_d/__about__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
__packagename__ = 'xcp_d'
1111
__copyright__ = 'Copyright 2020, PennLINC and DCAN labs'
1212
__credits__ = (
13-
'Contributors: please check the ``.zenodo.json`` file at the top-level folder'
14-
'of the repository'
13+
'Contributors: please check the ``.zenodo.json`` file at the top-level folderof the repository'
1514
)
1615
__url__ = 'https://github.com/PennLINC/xcp_d'
1716

xcp_d/_warnings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def _warn(message, category=None, stacklevel=1, source=None):
1313
category = type(category).__name__
1414
category = category.replace('type', 'WARNING')
1515

16-
logging.getLogger('py.warnings').warning(f"{category or 'WARNING'}: {message}")
16+
logging.getLogger('py.warnings').warning(f'{category or "WARNING"}: {message}')
1717

1818

1919
def _showwarning(message, category, filename, lineno, file=None, line=None):

xcp_d/cli/parser.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ def _build_parser():
119119
default=None,
120120
metavar='FILE',
121121
help=(
122-
"A JSON file describing custom BIDS input filters using PyBIDS. "
123-
"For further details, please check out "
124-
"https://xcp-d.readthedocs.io/en/"
125-
f"{currentv.base_version if is_release else 'latest'}/usage.html#"
126-
"filtering-inputs-with-bids-filter-files"
122+
'A JSON file describing custom BIDS input filters using PyBIDS. '
123+
'For further details, please check out '
124+
'https://xcp-d.readthedocs.io/en/'
125+
f'{currentv.base_version if is_release else "latest"}/usage.html#'
126+
'filtering-inputs-with-bids-filter-files'
127127
),
128128
)
129129
g_bids.add_argument(
@@ -868,7 +868,7 @@ def parse_args(args=None, namespace=None):
868868

869869
# Ensure input and output folders are not the same
870870
if output_dir == fmri_dir:
871-
rec_path = fmri_dir / 'derivatives' / f"xcp_d-{version.split('+')[0]}"
871+
rec_path = fmri_dir / 'derivatives' / f'xcp_d-{version.split("+")[0]}'
872872
parser.error(
873873
'The selected output folder is the same as the input BIDS folder. '
874874
f'Please modify the output path (suggestion: {rec_path}).'
@@ -897,8 +897,8 @@ def parse_args(args=None, namespace=None):
897897
missing_subjects = participant_label - set(all_subjects)
898898
if missing_subjects:
899899
parser.error(
900-
"One or more participant labels were not found in the BIDS directory: "
901-
f"{', '.join(missing_subjects)}."
900+
'One or more participant labels were not found in the BIDS directory: '
901+
f'{", ".join(missing_subjects)}.'
902902
)
903903

904904
config.execution.participant_label = sorted(participant_label)
@@ -1105,8 +1105,7 @@ def _validate_parameters(opts, build_log, parser):
11051105
and (opts.high_pass > 0 and opts.low_pass > 0)
11061106
):
11071107
parser.error(
1108-
f"'--lower-bpf' ({opts.high_pass}) must be lower than "
1109-
f"'--upper-bpf' ({opts.low_pass})."
1108+
f"'--lower-bpf' ({opts.high_pass}) must be lower than '--upper-bpf' ({opts.low_pass})."
11101109
)
11111110
elif not opts.bandpass_filter:
11121111
build_log.warning('Bandpass filtering is disabled. ALFF outputs will not be generated.')

xcp_d/cli/workflow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ def build_workflow(config_file, retval):
3030
notice_path = data.load.readable('NOTICE')
3131
if notice_path.exists():
3232
banner[0] += '\n'
33-
banner += [f"License NOTICE {'#' * 50}"]
33+
banner += [f'License NOTICE {"#" * 50}']
3434
banner += [f'XCP-D {version}']
3535
banner += notice_path.read_text().splitlines(keepends=False)[1:]
3636
banner += ['#' * len(banner[1])]
37-
build_log.log(25, f"\n{' ' * 9}".join(banner))
37+
build_log.log(25, f'\n{" " * 9}'.join(banner))
3838

3939
# warn if older results exist: check for dataset_description.json in output folder
4040
msg = check_pipeline_version(
@@ -95,7 +95,7 @@ def build_workflow(config_file, retval):
9595
if config.execution.datasets:
9696
init_msg += [f'Searching for derivatives and atlases: {config.execution.datasets}.']
9797

98-
build_log.log(25, f"\n{' ' * 11}* ".join(init_msg))
98+
build_log.log(25, f'\n{" " * 11}* '.join(init_msg))
9999

100100
retval['workflow'] = init_xcpd_wf()
101101

xcp_d/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
if _proc_oc_kbytes.exists():
202202
_oc_limit = _proc_oc_kbytes.read_text().strip()
203203
if _oc_limit in ('0', 'n/a') and Path('/proc/sys/vm/overcommit_ratio').exists():
204-
_oc_limit = f"{Path('/proc/sys/vm/overcommit_ratio').read_text().strip()}%"
204+
_oc_limit = f'{Path("/proc/sys/vm/overcommit_ratio").read_text().strip()}%'
205205
except Exception: # noqa: S110, BLE001
206206
pass
207207

@@ -416,7 +416,7 @@ class execution(_Config):
416416
"""Folder where derivatives will be stored."""
417417
atlases = []
418418
"""Selection of atlases to apply to the data."""
419-
run_uuid = f"{strftime('%Y%m%d-%H%M%S')}_{uuid4()}"
419+
run_uuid = f'{strftime("%Y%m%d-%H%M%S")}_{uuid4()}'
420420
"""Unique identifier of this particular run."""
421421
participant_label = None
422422
"""List of participant identifiers that are to be preprocessed."""

xcp_d/interfaces/censoring.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ class _RemoveDummyVolumesInputSpec(BaseInterfaceInputSpec):
3939
None,
4040
mandatory=False,
4141
desc=(
42-
'TSV file with selected confounds for denoising. '
43-
'May be None if denoising is disabled.'
42+
'TSV file with selected confounds for denoising. May be None if denoising is disabled.'
4443
),
4544
)
4645
confounds_images = traits.Either(
@@ -71,8 +70,7 @@ class _RemoveDummyVolumesOutputSpec(TraitedSpec):
7170
File(exists=True),
7271
None,
7372
desc=(
74-
'TSV file with selected confounds for denoising. '
75-
'May be None if denoising is disabled.'
73+
'TSV file with selected confounds for denoising. May be None if denoising is disabled.'
7674
),
7775
)
7876
confounds_images_dropped_TR = traits.Either(
@@ -386,8 +384,7 @@ def _run_interface(self, runtime):
386384
censoring_df.loc[random_censor, column_name] = 0
387385
temporal_mask_metadata[column_name] = {
388386
'Description': (
389-
f'Randomly selected low-motion volumes to retain exactly {exact_scan} '
390-
'volumes.'
387+
f'Randomly selected low-motion volumes to retain exactly {exact_scan} volumes.'
391388
),
392389
'Levels': {
393390
'0': 'Retained or high-motion volume',
@@ -905,9 +902,9 @@ def _run_interface(self, runtime):
905902
signal_regressors = [c for c in new_confound_df.columns if c.startswith('signal__')]
906903
if signal_regressors:
907904
LOGGER.warning(
908-
"Signal regressors detected. "
909-
"Orthogonalizing nuisance regressors w.r.t. the following signal regressors: "
910-
f"{', '.join(signal_regressors)}"
905+
'Signal regressors detected. '
906+
'Orthogonalizing nuisance regressors w.r.t. the following signal regressors: '
907+
f'{", ".join(signal_regressors)}'
911908
)
912909
noise_regressors = [c for c in new_confound_df.columns if not c.startswith('signal__')]
913910

@@ -936,15 +933,15 @@ def _run_interface(self, runtime):
936933
for col in noise_regressors:
937934
desc_str = (
938935
"This regressor is orthogonalized with respect to the 'signal' regressors "
939-
f"({', '.join(signal_regressors)}) after dummy scan removal, "
940-
"but prior to any censoring."
936+
f'({", ".join(signal_regressors)}) after dummy scan removal, '
937+
'but prior to any censoring.'
941938
)
942939

943940
col_metadata = {}
944941
if col in confounds_metadata.keys():
945942
col_metadata = confounds_metadata.pop(col)
946943
if 'Description' in col_metadata.keys():
947-
desc_str = f"{col_metadata['Description']} {desc_str}"
944+
desc_str = f'{col_metadata["Description"]} {desc_str}'
948945

949946
col_metadata['Description'] = desc_str
950947
confounds_metadata[f'{col}_orth'] = col_metadata

xcp_d/interfaces/execsummary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def generate_report(self, out_file=None):
328328
'LaTeX',
329329
f"""<pre>{text}</pre>
330330
<h3>Bibliography</h3>
331-
<pre>{load_data("boilerplate.bib").read_text()}</pre>
331+
<pre>{load_data('boilerplate.bib').read_text()}</pre>
332332
""",
333333
)
334334
)

xcp_d/interfaces/report.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ def _generate_segment(self):
150150
mean_relative_rms = str(round(qcfile['mean_relative_rms'][0], 4))
151151
max_relative_rms = str(round(qcfile['max_relative_rms'][0], 4))
152152
dvars = (
153-
f"{round(qcfile['mean_dvars_initial'][0], 4)}, "
154-
f"{round(qcfile['mean_dvars_final'][0], 4)}"
153+
f'{round(qcfile["mean_dvars_initial"][0], 4)}, '
154+
f'{round(qcfile["mean_dvars_final"][0], 4)}'
155155
)
156156
fd_dvars_correlation = (
157-
f"{round(qcfile['fd_dvars_correlation_initial'][0], 4)}, "
158-
f"{round(qcfile['fd_dvars_correlation_final'][0], 4)}"
157+
f'{round(qcfile["fd_dvars_correlation_initial"][0], 4)}, '
158+
f'{round(qcfile["fd_dvars_correlation_final"][0], 4)}'
159159
)
160160
num_vols_censored = str(round(qcfile['num_censored_volumes'][0], 4))
161161

xcp_d/interfaces/workbench.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,8 +1444,7 @@ class _CiftiSmoothInputSpec(_WBCommandInputSpec):
14441444
exists=True,
14451445
position=6,
14461446
argstr='-left-corrected-areas %s',
1447-
desc='vertex areas (as a metric) to use instead of computing them from '
1448-
'the left surface.',
1447+
desc='vertex areas (as a metric) to use instead of computing them from the left surface.',
14491448
)
14501449
right_surf = File(
14511450
exists=True,
@@ -1458,8 +1457,7 @@ class _CiftiSmoothInputSpec(_WBCommandInputSpec):
14581457
exists=True,
14591458
position=8,
14601459
argstr='-right-corrected-areas %s',
1461-
desc='vertex areas (as a metric) to use instead of computing them from '
1462-
'the right surface',
1460+
desc='vertex areas (as a metric) to use instead of computing them from the right surface',
14631461
)
14641462
cerebellum_surf = File(
14651463
exists=True,

0 commit comments

Comments
 (0)