Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STY: Apply ruff/refurb rules (FURB) #918

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions niworkflows/engine/tests/test_plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import operator
from types import SimpleNamespace

import pytest
Expand All @@ -8,10 +9,6 @@
from ..plugin import MultiProcPlugin


def add(x, y):
return x + y


def addall(inlist):
import time

Expand All @@ -28,7 +25,7 @@ def workflow(tmp_path):

# Generate many nodes and claim a lot of memory
add_nd = pe.MapNode(
niu.Function(function=add, input_names=['x', 'y'], output_names=['z']),
niu.Function(function=operator.add, input_names=['x', 'y'], output_names=['z']),
name='add',
iterfield=['x'],
mem_gb=0.8,
Expand All @@ -39,7 +36,7 @@ def workflow(tmp_path):

# Run without submitting is another code path
add_more_nd = pe.Node(
niu.Function(function=add, input_names=['x', 'y'], output_names=['z']),
niu.Function(function=operator.add, input_names=['x', 'y'], output_names=['z']),
name='add_more',
run_without_submitting=True,
)
Expand Down
2 changes: 1 addition & 1 deletion niworkflows/reports/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
self.packagename = packagename
self.subject_id = subject_id
if subject_id is not None:
self.subject_id = subject_id[4:] if subject_id.startswith('sub-') else subject_id
self.subject_id = subject_id.removeprefix('sub-')

Check warning on line 288 in niworkflows/reports/core.py

View check run for this annotation

Codecov / codecov/patch

niworkflows/reports/core.py#L288

Added line #L288 was not covered by tests
self.out_filename = f'sub-{self.subject_id}.html'

# Default template from niworkflows
Expand Down
2 changes: 1 addition & 1 deletion niworkflows/utils/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
participant_label = [participant_label]

# Drop sub- prefixes
participant_label = [sub[4:] if sub.startswith('sub-') else sub for sub in participant_label]
participant_label = [sub.removeprefix('sub-') for sub in participant_label]

Check warning on line 137 in niworkflows/utils/bids.py

View check run for this annotation

Codecov / codecov/patch

niworkflows/utils/bids.py#L137

Added line #L137 was not covered by tests
# Remove duplicates
participant_label = sorted(set(participant_label))
# Remove labels not found
Expand Down
13 changes: 7 additions & 6 deletions niworkflows/utils/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,13 @@


def _gen_skeleton(root):
dirs, files = [], []
files.append(root / 'file1')
files.append(root / '.file2')
dirs.append(root / 'subdir1')
files.append(dirs[0] / 'file3')
files.append(dirs[0] / '.file4')
dirs = [root / 'subdir1']
files = [

Check warning on line 87 in niworkflows/utils/tests/test_utils.py

View check run for this annotation

Codecov / codecov/patch

niworkflows/utils/tests/test_utils.py#L86-L87

Added lines #L86 - L87 were not covered by tests
root / 'file1',
root / '.file2',
dirs[0] / 'file3',
dirs[0] / '.file4',
]
for d in dirs:
d.mkdir()
for f in files:
Expand Down
Loading