Skip to content

Commit d9ff1cb

Browse files
authored
STY: Adopt ruff for linting and formatting (#3206)
Follow-up to nipreps/smriprep#397. This should replace #3185 and #3147. I would review this commit-by-commit, and skip c0f2183, which was a pretty safe run of `ruff format` and `ruff --fix`. It's dominated by quote changes, so I would ignore it. Everything else could stand a review.
2 parents f3e95d9 + 0728a27 commit d9ff1cb

Some content is hidden

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

74 files changed

+2740
-2873
lines changed

.git-blame-ignore-revs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
# 2022-09-22 - [email protected] - STY: black/isort the docker wrapper
1+
# 2024-01-16 - [email protected] - STY: ruff --fix --unsafe-fixes (with cleanup) [git-blame-ignore-rev]
2+
66734bd0164d1dae3cf299fa9d9d682c22eeda66
3+
# 2024-01-16 - [email protected] - STY: ruff format and ruff --fix [git-blame-ignore-rev]
4+
311686eb329d3594732429f7c3d50d212b8dc519
5+
# 2023-02-02 - [email protected] - STY: black [git-blame-ignore-rev]
6+
d3f380701b3953087475a18cf23c0fb388f7aed6
7+
# 2022-09-22 - [email protected] - STY: black/isort the docker wrapper
28
9976458388f369cba4b7d81359acc40b52f6621c
3-
# 2022-09-22 - [email protected] - STY: Apply black/isort to codebase
9+
# 2022-09-22 - [email protected] - STY: Apply black/isort to codebase
410
7eedab8b29497cee1d8dd540c2266e740f484a86
511
# 2021-11-05 - [email protected] - STY: Update black config
612
d2ad20301306f283d504ec7b5a1bd73ce58c2b11

.github/ISSUE_TEMPLATE/documentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ For the Documentation request, please include the following:
1111
------------------------
1212
What would you like changed/added and why?
1313
Do you have any suggestions for the new documents?
14-
-->
14+
-->

.github/workflows/contrib.yml

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,13 @@ permissions:
2222
contents: read
2323

2424
jobs:
25-
stable:
26-
runs-on: ${{ matrix.os }}
27-
strategy:
28-
matrix:
29-
os: ['ubuntu-latest']
30-
python-version: [3]
31-
25+
style:
26+
runs-on: ubuntu-latest
3227
steps:
3328
- uses: actions/checkout@v4
34-
- name: Set up Python ${{ matrix.python-version }}
35-
uses: actions/setup-python@v5
36-
with:
37-
python-version: ${{ matrix.python-version }}
38-
- name: Display Python version
39-
run: python -c "import sys; print(sys.version)"
40-
- name: Install black/isort
41-
run: python -m pip install black isort[colors]
42-
- name: Check fMRIPrep
43-
run: |
44-
python -m black --diff --color --check fmriprep
45-
python -m isort --diff --color --check fmriprep
46-
- name: Check wrapper
47-
run: |
48-
python -m black --diff --color --check wrapper
49-
python -m isort --diff --color --check wrapper
50-
29+
- run: pipx run ruff fmriprep
30+
- run: pipx run ruff format --diff fmriprep
31+
5132
codespell:
5233
name: Check for spelling errors
5334
runs-on: ubuntu-latest

.maint/ci/install_dependencies.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if [ "$OS_TYPE" = "ubuntu-latest" ]; then
1313
elif [ "$OS_TYPE" = "macos-latest" ]; then
1414
brew install graphviz
1515
else
16-
echo "Unknown OS_TYPE: $OS_TYPE"
16+
echo "Unknown OS_TYPE: $OS_TYPE"
1717
fi
1818

1919
set +eux

.maint/former.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
{
33
"name": "Berleant, Shoshana"
44
}
5-
]
5+
]

.maint/paper_author_list.py

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env python3
22
"""Generate an author list for a new paper or abstract."""
3+
import json
34
import sys
45
from pathlib import Path
5-
import json
6-
from update_zenodo import get_git_lines, sort_contributors
76

7+
from update_zenodo import get_git_lines, sort_contributors
88

99
# These authors should go last
1010
AUTHORS_LAST = ['Gorgolewski, Krzysztof J.', 'Poldrack, Russell A.', 'Esteban, Oscar']
@@ -21,9 +21,11 @@ def _aslist(inlist):
2121
contribs = json.loads(Path('.maint/contributors.json').read_text())
2222

2323
author_matches, unmatched = sort_contributors(
24-
devs + contribs, get_git_lines(),
24+
devs + contribs,
25+
get_git_lines(),
2526
exclude=json.loads(Path('.maint/former.json').read_text()),
26-
last=AUTHORS_LAST)
27+
last=AUTHORS_LAST,
28+
)
2729
# Remove position
2830
affiliations = []
2931
for item in author_matches:
@@ -32,18 +34,34 @@ def _aslist(inlist):
3234
if a not in affiliations:
3335
affiliations.append(a)
3436

35-
aff_indexes = [', '.join(['%d' % (affiliations.index(a) + 1)
36-
for a in _aslist(author.get('affiliation', 'Unaffiliated'))])
37-
for author in author_matches]
37+
aff_indexes = [
38+
', '.join(
39+
[
40+
'%d' % (affiliations.index(a) + 1)
41+
for a in _aslist(author.get('affiliation', 'Unaffiliated'))
42+
]
43+
)
44+
for author in author_matches
45+
]
3846

39-
print("Some people made commits, but are missing in .maint/ "
40-
"files: %s." % ', '.join(unmatched), file=sys.stderr)
47+
print(
48+
'Some people made commits, but are missing in .maint/ '
49+
'files: %s.' % ', '.join(unmatched),
50+
file=sys.stderr,
51+
)
4152

4253
print('Authors (%d):' % len(author_matches))
43-
print("%s." % '; '.join([
44-
'%s \\ :sup:`%s`\\ ' % (i['name'], idx)
45-
for i, idx in zip(author_matches, aff_indexes)
46-
]))
54+
print(
55+
'%s.'
56+
% '; '.join(
57+
[
58+
'{} \\ :sup:`{}`\\ '.format(i['name'], idx)
59+
for i, idx in zip(author_matches, aff_indexes, strict=False)
60+
]
61+
)
62+
)
4763

48-
print('\n\nAffiliations:\n%s' % '\n'.join(['{0: >2}. {1}'.format(i + 1, a)
49-
for i, a in enumerate(affiliations)]))
64+
print(
65+
'\n\nAffiliations:\n%s'
66+
% '\n'.join([f'{i + 1: >2}. {a}' for i, a in enumerate(affiliations)])
67+
)

0 commit comments

Comments
 (0)