Skip to content

Commit

Permalink
STY: Adopt ruff for linting and formatting (#3206)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
effigies committed Feb 5, 2024
2 parents f3e95d9 + 0728a27 commit d9ff1cb
Show file tree
Hide file tree
Showing 74 changed files with 2,740 additions and 2,873 deletions.
10 changes: 8 additions & 2 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# 2022-09-22 - goncalves.mathias@gmail.com - STY: black/isort the docker wrapper
# 2024-01-16 - effigies@gmail.com - STY: ruff --fix --unsafe-fixes (with cleanup) [git-blame-ignore-rev]
66734bd0164d1dae3cf299fa9d9d682c22eeda66
# 2024-01-16 - effigies@gmail.com - STY: ruff format and ruff --fix [git-blame-ignore-rev]
311686eb329d3594732429f7c3d50d212b8dc519
# 2023-02-02 - effigies@gmail.com - STY: black [git-blame-ignore-rev]
d3f380701b3953087475a18cf23c0fb388f7aed6
# 2022-09-22 - mathiasg@stanford.edu - STY: black/isort the docker wrapper
9976458388f369cba4b7d81359acc40b52f6621c
# 2022-09-22 - goncalves.mathias@gmail.com - STY: Apply black/isort to codebase
# 2022-09-22 - mathiasg@stanford.edu - STY: Apply black/isort to codebase
7eedab8b29497cee1d8dd540c2266e740f484a86
# 2021-11-05 - markiewicz@stanford.edu - STY: Update black config
d2ad20301306f283d504ec7b5a1bd73ce58c2b11
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ For the Documentation request, please include the following:
------------------------
What would you like changed/added and why?
Do you have any suggestions for the new documents?
-->
-->
29 changes: 5 additions & 24 deletions .github/workflows/contrib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,13 @@ permissions:
contents: read

jobs:
stable:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-latest']
python-version: [3]

style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install black/isort
run: python -m pip install black isort[colors]
- name: Check fMRIPrep
run: |
python -m black --diff --color --check fmriprep
python -m isort --diff --color --check fmriprep
- name: Check wrapper
run: |
python -m black --diff --color --check wrapper
python -m isort --diff --color --check wrapper
- run: pipx run ruff fmriprep
- run: pipx run ruff format --diff fmriprep

codespell:
name: Check for spelling errors
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .maint/ci/install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if [ "$OS_TYPE" = "ubuntu-latest" ]; then
elif [ "$OS_TYPE" = "macos-latest" ]; then
brew install graphviz
else
echo "Unknown OS_TYPE: $OS_TYPE"
echo "Unknown OS_TYPE: $OS_TYPE"
fi

set +eux
Expand Down
2 changes: 1 addition & 1 deletion .maint/former.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
{
"name": "Berleant, Shoshana"
}
]
]
48 changes: 33 additions & 15 deletions .maint/paper_author_list.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env python3
"""Generate an author list for a new paper or abstract."""
import json
import sys
from pathlib import Path
import json
from update_zenodo import get_git_lines, sort_contributors

from update_zenodo import get_git_lines, sort_contributors

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

author_matches, unmatched = sort_contributors(
devs + contribs, get_git_lines(),
devs + contribs,
get_git_lines(),
exclude=json.loads(Path('.maint/former.json').read_text()),
last=AUTHORS_LAST)
last=AUTHORS_LAST,
)
# Remove position
affiliations = []
for item in author_matches:
Expand All @@ -32,18 +34,34 @@ def _aslist(inlist):
if a not in affiliations:
affiliations.append(a)

aff_indexes = [', '.join(['%d' % (affiliations.index(a) + 1)
for a in _aslist(author.get('affiliation', 'Unaffiliated'))])
for author in author_matches]
aff_indexes = [
', '.join(
[
'%d' % (affiliations.index(a) + 1)
for a in _aslist(author.get('affiliation', 'Unaffiliated'))
]
)
for author in author_matches
]

print("Some people made commits, but are missing in .maint/ "
"files: %s." % ', '.join(unmatched), file=sys.stderr)
print(
'Some people made commits, but are missing in .maint/ '
'files: %s.' % ', '.join(unmatched),
file=sys.stderr,
)

print('Authors (%d):' % len(author_matches))
print("%s." % '; '.join([
'%s \\ :sup:`%s`\\ ' % (i['name'], idx)
for i, idx in zip(author_matches, aff_indexes)
]))
print(
'%s.'
% '; '.join(
[
'{} \\ :sup:`{}`\\ '.format(i['name'], idx)
for i, idx in zip(author_matches, aff_indexes, strict=False)
]
)
)

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

0 comments on commit d9ff1cb

Please sign in to comment.