Skip to content

Commit 73ad292

Browse files
authored
Remove flake8, pydocstyle, black, etc. in favor of ruff (#1203)
* remove flake8, pydocstyle * ruff: use 'UP' and 'I' configs * remove black * run: ruff --format . * run ruff check --fix mne_bids * run: ruff check --fix examples/ --ignore=D103,D400,D205 * add ruff format as precommit hook * run: pre-commit run -a * fix botched autofixe * remove 'UP' config for ruff again, it's done its job * add and run new pre-commit hooks (yaml, EOL, ...) * run some pre-commit hooks in CI * fix python AST * do not need to run pre-commit checks in ci, we have pre-commit.ci CI * fix pyproj section name for pytest
1 parent 0779cc7 commit 73ad292

Some content is hidden

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

50 files changed

+416
-478
lines changed

.github/workflows/cffconvert.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- CITATION.cff
77
pull_request:
88
paths:
9-
- CITATION.cff
9+
- CITATION.cff
1010

1111
jobs:
1212
validate:

.github/workflows/unit_tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ jobs:
2121
python-version: ["3.12"]
2222
steps:
2323
- uses: actions/checkout@v4
24-
- uses: psf/black@stable
2524
- name: Set up Python ${{ matrix.python-version }}
2625
uses: actions/setup-python@v4
2726
with:
@@ -33,7 +32,7 @@ jobs:
3332
- name: Install dependencies
3433
run: |
3534
python -m pip install --upgrade pip
36-
pip install pydocstyle flake8 check-manifest black
35+
python -m pip install ruff check-manifest
3736
- name: Display versions and environment information
3837
run: |
3938
python --version

.pre-commit-config.yaml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
repos:
2-
- repo: https://github.com/psf/black
3-
rev: 23.11.0
4-
hooks:
5-
- id: black
6-
args: [--quiet]
7-
82
- repo: https://github.com/astral-sh/ruff-pre-commit
93
rev: v0.1.6
104
hooks:
@@ -18,3 +12,21 @@ repos:
1812
# D205: 1 blank line required between summary line and description
1913
args: ["--ignore=D103,D400,D205"]
2014
files: ^examples/
15+
- id: ruff-format
16+
name: ruff format mne_bids/
17+
files: ^mne_bids/
18+
- id: ruff-format
19+
name: ruff format examples/
20+
files: ^examples/
21+
22+
- repo: https://github.com/pre-commit/pre-commit-hooks
23+
rev: v4.5.0
24+
hooks:
25+
- id: trailing-whitespace
26+
- id: end-of-file-fixer
27+
- id: check-yaml
28+
- id: check-json
29+
- id: check-ast
30+
- id: check-added-large-files
31+
- id: check-case-conflict
32+
- id: check-docstring-first

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ you can simply use the following command from the root of the `mne-bids` reposit
116116
make pep
117117
```
118118

119-
We use [Black](https://github.com/psf/black) to format our code.
120-
You can simply call `black .` from the root of the `mne-bids` repository
119+
We use [ruff](https://docs.astral.sh/ruff/) to format our code.
120+
You can simply call `make ruff-format` from the root of the `mne-bids` repository
121121
to automatically convert your code to follow the appropriate style.
122122

123123
### git pre-commit hooks

LICENSE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
2727
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2828
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2929
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30-

Makefile

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: all clean-pyc clean-so clean-build clean-ctags clean-cache clean-e clean inplace test check-manifest flake black pydocstyle pep build-doc dist-build
1+
.PHONY: all clean-pyc clean-so clean-build clean-ctags clean-cache clean-e clean inplace test check-manifest ruff-check ruff-format pep build-doc dist-build
22

33
all: clean inplace pep test build-doc dist-build
44

@@ -24,7 +24,7 @@ clean-e:
2424
clean: clean-build clean-pyc clean-so clean-ctags clean-cache clean-e
2525

2626
inplace:
27-
@python -m pip install -e .[full]
27+
@python -m pip install -e .[dev]
2828

2929
test:
3030
@echo "Running tests"
@@ -41,19 +41,17 @@ check-manifest:
4141
@echo "Checking MANIFEST.in"
4242
@check-manifest .
4343

44-
flake:
45-
@echo "Running flake8"
46-
@flake8 --count mne_bids examples
44+
ruff-format:
45+
@echo "Running ruff format"
46+
@ruff format mne_bids/
47+
@ruff format examples/
4748

48-
black:
49-
@echo "Running black"
50-
@black --check .
49+
ruff-check:
50+
@echo "Running ruff check"
51+
@ruff check mne_bids/
52+
@ruff check examples/ --ignore=D103,D400,D205
5153

52-
pydocstyle:
53-
@echo "Running pydocstyle"
54-
@pydocstyle .
55-
56-
pep: flake pydocstyle check-manifest black
54+
pep: ruff-check check-manifest ruff-format
5755

5856
build-doc:
5957
@echo "Building documentation"
@@ -64,4 +62,6 @@ build-doc:
6462
dist-build:
6563
@echo "Building dist"
6664
rm -rf dist
65+
@python -m pip install wheel setuptools build twine
6766
@python -m build
67+
@python -m twine check --strict dist/*

examples/anonymize_dataset.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@
2424
# %%
2525
import shutil
2626
from pathlib import Path
27+
2728
import mne
29+
2830
from mne_bids import (
2931
BIDSPath,
30-
write_raw_bids,
32+
anonymize_dataset,
33+
print_dir_tree,
3134
write_anat,
3235
write_meg_calibration,
3336
write_meg_crosstalk,
34-
anonymize_dataset,
35-
print_dir_tree,
37+
write_raw_bids,
3638
)
3739

3840
data_path = Path(mne.datasets.sample.data_path())

examples/convert_eeg_to_bids.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import mne
3535
from mne.datasets import eegbci
3636

37-
from mne_bids import write_raw_bids, BIDSPath, print_dir_tree
37+
from mne_bids import BIDSPath, print_dir_tree, write_raw_bids
3838
from mne_bids.stats import count_events
3939

4040
# %%
@@ -221,7 +221,7 @@
221221
# If you are preparing a manuscript, please make sure to also cite MNE-BIDS
222222
# there.
223223
readme = op.join(bids_root, "README")
224-
with open(readme, "r", encoding="utf-8-sig") as fid:
224+
with open(readme, encoding="utf-8-sig") as fid:
225225
text = fid.read()
226226
print(text)
227227

examples/convert_empty_room.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@
3131

3232
import os.path as op
3333
import shutil
34-
3534
from datetime import datetime, timezone
3635

3736
import mne
3837
from mne.datasets import sample
3938

40-
from mne_bids import write_raw_bids, read_raw_bids, BIDSPath, print_dir_tree
39+
from mne_bids import BIDSPath, print_dir_tree, read_raw_bids, write_raw_bids
4140

4241
# %%
4342
# And define the paths and event_id dictionary.

examples/convert_group_studies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
from mne.datasets import eegbci
2727

2828
from mne_bids import (
29-
write_raw_bids,
3029
BIDSPath,
3130
get_anonymization_daysback,
3231
make_report,
3332
print_dir_tree,
33+
write_raw_bids,
3434
)
3535
from mne_bids.stats import count_events
3636

0 commit comments

Comments
 (0)