Skip to content

Commit ccc3928

Browse files
authored
Merge pull request #397 from effigies/sty/ruff
STY: Adopt ruff for linting and formatting
2 parents 3b0dcdb + 7e040be commit ccc3928

33 files changed

+1790
-1757
lines changed

.git-blame-ignore-revs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# 2023-11-21 - [email protected] - STY: ruff --fix smriprep [git-blame-ignore-rev]
2+
3a586cf46cb1bb963b93d9546f20273194d15de5
3+
# 2023-11-20 - [email protected] - STY: ruff --fix smriprep [git-blame-ignore-rev]
4+
c5e8b6b8ddb69284a4cba58e2512b299f1e29464
5+
# 2023-11-20 - [email protected] - STY: ruff format smriprep [git-blame-ignore-rev]
6+
8d62c0f3f3c6a911b1dfe2e9a2016b8de7da051a

.github/workflows/pythonpackage.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ jobs:
112112
- uses: codecov/codecov-action@v3
113113
name: Submit to CodeCov
114114

115-
flake8:
115+
style:
116116
if: "!contains(github.event.head_commit.message, '[skip ci]')"
117117
runs-on: ubuntu-latest
118118
steps:
119119
- uses: actions/checkout@v4
120-
- run: pipx run flake8 smriprep
120+
- run: pipx run ruff smriprep
121+
- run: pipx run ruff format --diff smriprep

.pre-commit-config.yaml

+4-13
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,8 @@ repos:
1010
- id: check-added-large-files
1111
- id: check-toml
1212
- id: check-json
13-
- repo: https://github.com/pycqa/flake8
14-
rev: 6.0.0
13+
- repo: https://github.com/astral-sh/ruff-pre-commit
14+
rev: v0.1.6
1515
hooks:
16-
- id: flake8
17-
# - repo: https://github.com/psf/black
18-
# rev: 23.1.0
19-
# hooks:
20-
# - id: black
21-
# files: ^smriprep/|^wrapper/
22-
# - repo: https://github.com/pycqa/isort
23-
# rev: 5.12.0
24-
# hooks:
25-
# - id: isort
26-
# files: ^smriprep/|^wrapper/
16+
- id: ruff
17+
- id: ruff-format

Makefile

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help docker
1+
.PHONY: help docker .git-blame-ignore-revs
22
.DEFAULT: help
33

44
tag="latest"
@@ -15,3 +15,9 @@ docker:
1515
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
1616
--build-arg VCS_REF=`git rev-parse --short HEAD` \
1717
--build-arg VERSION=`python setup.py --version` .
18+
19+
20+
.git-blame-ignore-revs:
21+
git log --grep "\[git-blame-ignore-rev\]" --pretty=format:"# %ad - %ae - %s%n%H" --date short \
22+
> .git-blame-ignore-revs
23+
echo >> .git-blame-ignore-revs

pyproject.toml

+35-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ version-file = "smriprep/_version.py"
9999

100100
[tool.black]
101101
line-length = 99
102-
target-version = ['py39']
103102
skip-string-normalization = true
104103

105104
[tool.isort]
@@ -136,3 +135,38 @@ source = [
136135
"smriprep/",
137136
"*/site-packages/smriprep",
138137
]
138+
139+
[tool.ruff]
140+
line-length = 99
141+
extend-select = [
142+
"F",
143+
"E",
144+
"W",
145+
"I",
146+
"UP",
147+
"YTT",
148+
"S",
149+
"BLE",
150+
"B",
151+
"A",
152+
# "CPY",
153+
"C4",
154+
"DTZ",
155+
"T10",
156+
# "EM",
157+
"EXE",
158+
"FA",
159+
"ISC",
160+
"ICN",
161+
"PT",
162+
"Q",
163+
]
164+
165+
[tool.ruff.flake8-quotes]
166+
inline-quotes = "single"
167+
168+
[tool.ruff.extend-per-file-ignores]
169+
"*/test_*.py" = ["S101"]
170+
171+
[tool.ruff.format]
172+
quote-style = "single"

smriprep/__about__.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,15 @@
2727
try:
2828
from ._version import __version__
2929
except ImportError: # pragma: no cover
30-
__version__ = "0+unknown"
30+
__version__ = '0+unknown'
3131

32-
__copyright__ = "Copyright 2019, Center for Reproducible Neuroscience, Stanford University"
32+
__copyright__ = 'Copyright 2019, Center for Reproducible Neuroscience, Stanford University'
3333
__credits__ = [
34-
"Oscar Esteban",
35-
"Chris Gorgolewski",
36-
"Christopher J. Markiewicz",
37-
"Russell A. Poldrack",
34+
'Oscar Esteban',
35+
'Chris Gorgolewski',
36+
'Christopher J. Markiewicz',
37+
'Russell A. Poldrack',
3838
]
39-
__url__ = "https://github.com/nipreps/smriprep"
39+
__url__ = 'https://github.com/nipreps/smriprep'
4040

41-
DOWNLOAD_URL = "https://github.com/nipreps/{name}/archive/{ver}.tar.gz".format(
42-
name=__package__, ver=__version__
43-
)
41+
DOWNLOAD_URL = f'https://github.com/nipreps/{__package__}/archive/{__version__}.tar.gz'

smriprep/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
)
1616

1717
__all__ = [
18-
"__copyright__",
19-
"__credits__",
20-
"__version__",
18+
'__copyright__',
19+
'__credits__',
20+
'__version__',
2121
]

smriprep/__main__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
#
2323
from .cli.run import main
2424

25-
if __name__ == "__main__":
25+
if __name__ == '__main__':
2626
import sys
2727

2828
# `python -m smriprep` typically displays the command as __main__.py
29-
if "__main__.py" in sys.argv[0]:
30-
sys.argv[0] = "%s -m smriprep" % sys.executable
29+
if '__main__.py' in sys.argv[0]:
30+
sys.argv[0] = '%s -m smriprep' % sys.executable
3131
main()

0 commit comments

Comments
 (0)