Skip to content

Commit 0cad6f6

Browse files
authored
STY: Enforce more ruff rules (#3437)
2 parents 234d2eb + 91c89cc commit 0cad6f6

File tree

16 files changed

+49
-35
lines changed

16 files changed

+49
-35
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ repos:
1212
- id: check-toml
1313
- id: check-added-large-files
1414
- repo: https://github.com/astral-sh/ruff-pre-commit
15-
rev: v0.12.2
15+
rev: v0.13.0
1616
hooks:
1717
- id: ruff-check
1818
args: [ --fix ]

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
sys.path.append(os.path.abspath('sphinxext'))
2323
sys.path.insert(0, os.path.abspath('../wrapper'))
2424

25-
from github_link import make_linkcode_resolve # noqa: E402
25+
from github_link import make_linkcode_resolve
2626

2727
# -- General configuration ------------------------------------------------
2828

fmriprep/cli/tests/test_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def test_derivatives(tmp_path):
254254
# Providing --derivatives with names should use them
255255
temp_args = args + [
256256
'--derivatives',
257-
f'anat={str(bids_path / "derivatives/smriprep")}',
257+
f'anat={bids_path / "derivatives/smriprep"}',
258258
]
259259
opts = parser.parse_args(temp_args)
260260
assert opts.derivatives == {'anat': bids_path / 'derivatives/smriprep'}

fmriprep/cli/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def check_latest():
7272
versions = [Version(rel) for rel in response.json()['releases'].keys()]
7373
versions = [rel for rel in versions if not rel.is_prerelease]
7474
if versions:
75-
latest = sorted(versions)[-1]
75+
latest = max(versions)
7676
else:
7777
latest = None
7878

fmriprep/config.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,7 @@ def _process_value(value):
540540
'raw': cls.bids_dir,
541541
'templateflow': Path(TF_LAYOUT.root),
542542
}
543-
for deriv_name, deriv_path in cls.derivatives.items():
544-
dataset_links[deriv_name] = deriv_path
543+
dataset_links.update(cls.derivatives)
545544
cls.dataset_links = dataset_links
546545

547546
if 'all' in cls.debug:
@@ -794,9 +793,7 @@ def get(flat=False):
794793
return settings
795794

796795
return {
797-
'.'.join((section, k)): v
798-
for section, configs in settings.items()
799-
for k, v in configs.items()
796+
f'{section}.{k}': v for section, configs in settings.items() for k, v in configs.items()
800797
}
801798

802799

fmriprep/interfaces/confounds.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,8 @@ def less_breakable(a_string):
429429
# Taken from https://stackoverflow.com/questions/1175208/
430430
# If we end up using it more than just here, probably worth pulling in a well-tested package
431431
def camel_to_snake(name):
432-
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
433-
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
432+
s1 = re.sub(r'(.)([A-Z][a-z]+)', r'\1_\2', name)
433+
return re.sub(r'([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
434434

435435
def _adjust_indices(left_df, right_df):
436436
# This forces missing values to appear at the beginning of the DataFrame

fmriprep/interfaces/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import os
1111
from contextlib import contextmanager
1212

13-
@contextmanager # type: ignore
13+
@contextmanager
1414
def _chdir(path):
1515
cwd = os.getcwd()
1616
os.chdir(path)

fmriprep/interfaces/reports.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ def _run_interface(self, runtime):
131131
def _generate_segment(self):
132132
BIDS_NAME = re.compile(
133133
r'^(.*\/)?'
134-
'(?P<subject_id>sub-[a-zA-Z0-9]+)'
135-
'(_(?P<session_id>ses-[a-zA-Z0-9]+))?'
136-
'(_(?P<task_id>task-[a-zA-Z0-9]+))?'
137-
'(_(?P<acq_id>acq-[a-zA-Z0-9]+))?'
138-
'(_(?P<rec_id>rec-[a-zA-Z0-9]+))?'
139-
'(_(?P<run_id>run-[a-zA-Z0-9]+))?'
134+
r'(?P<subject_id>sub-[a-zA-Z0-9]+)'
135+
r'(_(?P<session_id>ses-[a-zA-Z0-9]+))?'
136+
r'(_(?P<task_id>task-[a-zA-Z0-9]+))?'
137+
r'(_(?P<acq_id>acq-[a-zA-Z0-9]+))?'
138+
r'(_(?P<rec_id>rec-[a-zA-Z0-9]+))?'
139+
r'(_(?P<run_id>run-[a-zA-Z0-9]+))?'
140140
)
141141

142142
if not isdefined(self.inputs.subjects_dir):

fmriprep/interfaces/workbench.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def _format_arg(self, opt, spec, val):
292292
if opt == 'valid_roi_out' and val:
293293
# generate a filename and add it to argstr
294294
roi_out = self._gen_filename(self.inputs.in_file, suffix='_roi')
295-
iflogger.info('Setting roi output file as', roi_out)
295+
iflogger.info('Setting roi output file as %s', roi_out)
296296
spec.argstr += ' ' + roi_out
297297
return super()._format_arg(opt, spec, val)
298298

fmriprep/utils/telemetry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def before_send(event, hints):
156156
return None
157157
if msg.startswith('Saving crash info to '):
158158
return None
159-
if re.match('Node .+ failed to run on host .+', msg):
159+
if re.match(r'Node .+ failed to run on host .+', msg):
160160
return None
161161

162162
if 'breadcrumbs' in event and isinstance(event['breadcrumbs'], list):

0 commit comments

Comments
 (0)