Skip to content

Commit

Permalink
feat: replace flake8 with faster ruff
Browse files Browse the repository at this point in the history
Note: for anyone doing testing on an existing install, this DOES require
that you will have to install the `ruff` Python package. Alternatively,
you can also install `ruff` by re-installing the development packages
the same way you originally installed `flake8`, via:

`pip install --editable "<your_hnn_dir>[dev]"`
  • Loading branch information
asoplata committed Dec 17, 2024
1 parent 6c69538 commit 2295fc8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/unix_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
shell: bash -el {0}
run: |
pip install --verbose '.[opt, parallel, test, gui]'
- name: Lint with flake8
- name: Lint with ruff
shell: bash -el {0}
run: |
flake8 --count hnn_core
ruff check hnn_core
- name: Test non-MPI, embarrassingly parallel tests with pytest
shell: bash -el {0}
run: |
Expand Down
13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ clean :
check-manifest:
check-manifest

test: flake
test: lint
pytest ./hnn_core/tests/ -m "not uses_mpi" -n auto
pytest ./hnn_core/tests/ -m "uses_mpi"

flake:
@if command -v flake8 > /dev/null; then \
echo "Running flake8"; \
flake8 hnn_core --count; \
lint:
@if command -v ruff > /dev/null; then \
echo "Running ruff check"; \
ruff check hnn_core; \
else \
echo "flake8 not found, please install it!"; \
echo "ruff not found, please install it!"; \
exit 1; \
fi;
@echo "flake8 passed"
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ check-hidden = true
# in jupyter notebooks - images and also some embedded outputs
ignore-regex = '^\s*"image/\S+": ".*|.*%22%3A%20.*'
ignore-words-list = 'tha,nam,sherif,dout'

[tool.ruff]
exclude = ["*.ipynb"]
[tool.ruff.lint]
exclude = ["__init__.py"]
# We don't include rule "W504", which was in our old flake8 "setup.cfg" file, because the ruff
# linter does not detect it.
ignore = [
"E722", # From original flake8 'setup.cfg' file, needed in gui.py and viz.py
]
4 changes: 0 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[flake8]
exclude = __init__.py
ignore = E722, W504

[check-manifest]
ignore =
.circleci/*
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def run(self):
extras = {
'opt': ['scikit-learn'],
'parallel': ['joblib', 'psutil'],
'test': ['flake8', 'pytest', 'pytest-cov', 'pytest-xdist'],
'test': ['pytest', 'pytest-cov', 'pytest-xdist', 'ruff'],
'docs': ['mne', 'nibabel', 'pooch', 'tdqm',
'sphinx', 'sphinx-gallery',
'sphinx_bootstrap_theme', 'sphinx-copybutton',
Expand Down

0 comments on commit 2295fc8

Please sign in to comment.