From 2295fc86bb59abc71e4b5db482daf53eefb68b6b Mon Sep 17 00:00:00 2001 From: "Austin E. Soplata" Date: Fri, 13 Dec 2024 16:34:46 -0500 Subject: [PATCH] feat: replace flake8 with faster ruff 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 "[dev]"` --- .github/workflows/unix_unit_tests.yml | 4 ++-- Makefile | 13 ++++++------- pyproject.toml | 10 ++++++++++ setup.cfg | 4 ---- setup.py | 2 +- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.github/workflows/unix_unit_tests.yml b/.github/workflows/unix_unit_tests.yml index 7648f8000..cc8008ace 100644 --- a/.github/workflows/unix_unit_tests.yml +++ b/.github/workflows/unix_unit_tests.yml @@ -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: | diff --git a/Makefile b/Makefile index 67e1d3a99..11ddb638b 100644 --- a/Makefile +++ b/Makefile @@ -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" diff --git a/pyproject.toml b/pyproject.toml index 25cd619b7..a743f2d77 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 +] \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index f6c32644d..cd3994bff 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,3 @@ -[flake8] -exclude = __init__.py -ignore = E722, W504 - [check-manifest] ignore = .circleci/* diff --git a/setup.py b/setup.py index 8887be1ed..b6b0724b7 100644 --- a/setup.py +++ b/setup.py @@ -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',