From 81b3690e103d4a6db5bbc1cfce04f10e6c1a7d5c Mon Sep 17 00:00:00 2001 From: esavary Date: Thu, 21 Mar 2024 15:29:51 +0100 Subject: [PATCH 01/10] CI: replace flake8 by ruff check --- .github/workflows/contrib.yml | 4 +-- pyproject.toml | 56 ++++++++++++++++++++++++++++------- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/.github/workflows/contrib.yml b/.github/workflows/contrib.yml index c0f1a005..1438300e 100755 --- a/.github/workflows/contrib.yml +++ b/.github/workflows/contrib.yml @@ -7,7 +7,7 @@ defaults: jobs: stable: - name: Run flake8 + name: Run ruff runs-on: ubuntu-latest steps: @@ -20,4 +20,4 @@ jobs: with: python-version: 3 - name: Lint EddyMotion - run: pipx run flake8-pyproject + run: pipx run ruff check diff --git a/pyproject.toml b/pyproject.toml index 317a96e9..ce11e6cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -136,18 +136,54 @@ exclude = ''' profile = 'black' skip_gitignore = true -[tool.flake8] -max-line-length = 99 -doctests = false -exclude = ["*build/", "docs/"] -select = "C,E,F,W,B,B950" -ignore = "N802,N806,W503,E203" -per-file-ignores = [ - "*/__init__.py: F401", - "docs/conf.py: E265", - "/^\\s*\\.\\. _.*?: http/: E501" +[tool.ruff] +line-length = 99 + +[tool.ruff.lint] +extend-select = [ + "F", + "E", + "W", + "I", + "UP", + "YTT", + "S", + "BLE", + "B", + "A", + # "CPY", + "C4", + "DTZ", + "T10", + # "EM", + "EXE", + "FA", + "ISC", + "ICN", + "PT", + "Q", +] +ignore = [ + "S311", # We are not using random for cryptographic purposes + "ISC001", + "S603", ] +[tool.ruff.lint.flake8-quotes] +inline-quotes = "single" + +[tool.ruff.lint.extend-per-file-ignores] +"*/test_*.py" = ["S101"] +"docs/source/conf.py" = ["A001"] +"mriqc/bin/nib_hash.py" = ["S324"] +"mriqc/config.py" = ["S105"] +"mriqc/conftest.py" = ["PT004"] +"mriqc/engine/plugin.py" = ["BLE001"] +"mriqc/utils/debug.py" = ["A002", "T100"] + +[tool.ruff.format] +quote-style = "single" + [tool.pytest.ini_options] pythonpath = "src/ test/" norecursedirs = [".*", "_*"] From e7b5ab0b78281e298252d875048476c4d5c41181 Mon Sep 17 00:00:00 2001 From: esavary Date: Thu, 21 Mar 2024 16:15:04 +0100 Subject: [PATCH 02/10] fix: ruff configuration lines --- pyproject.toml | 40 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ce11e6cd..7a029dd9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -143,46 +143,28 @@ line-length = 99 extend-select = [ "F", "E", + "C", "W", - "I", - "UP", - "YTT", - "S", - "BLE", "B", - "A", - # "CPY", - "C4", - "DTZ", - "T10", - # "EM", - "EXE", - "FA", - "ISC", - "ICN", - "PT", - "Q", + "B950", ] ignore = [ - "S311", # We are not using random for cryptographic purposes - "ISC001", - "S603", + "N802", + "N806", + "W503", + "E203", ] [tool.ruff.lint.flake8-quotes] -inline-quotes = "single" +inline-quotes = "double" [tool.ruff.lint.extend-per-file-ignores] -"*/test_*.py" = ["S101"] -"docs/source/conf.py" = ["A001"] -"mriqc/bin/nib_hash.py" = ["S324"] -"mriqc/config.py" = ["S105"] -"mriqc/conftest.py" = ["PT004"] -"mriqc/engine/plugin.py" = ["BLE001"] -"mriqc/utils/debug.py" = ["A002", "T100"] +"*/__init__.py" = ["F401"] +"docs/conf.py" = ["E265"] +"/^\\s*\\.\\. _.*?: http/" = ["E501"] [tool.ruff.format] -quote-style = "single" +quote-style = "double" [tool.pytest.ini_options] pythonpath = "src/ test/" From bdbbc31d88a61e25587f0c2240d4130c4d5224d2 Mon Sep 17 00:00:00 2001 From: esavary Date: Thu, 21 Mar 2024 16:24:28 +0100 Subject: [PATCH 03/10] fix: remove Bugbear violation for line length --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7a029dd9..7eab69dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -146,7 +146,6 @@ extend-select = [ "C", "W", "B", - "B950", ] ignore = [ "N802", From 32dea8c79d7b60c041acc9500a58a528d83c0e8c Mon Sep 17 00:00:00 2001 From: esavary Date: Thu, 21 Mar 2024 16:28:29 +0100 Subject: [PATCH 04/10] fix: remove W503 --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7eab69dc..88eb96cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -150,7 +150,6 @@ extend-select = [ ignore = [ "N802", "N806", - "W503", "E203", ] From ca13bc25098c6c325f3a20e99b7f6d9ac30e0672 Mon Sep 17 00:00:00 2001 From: esavary Date: Fri, 22 Mar 2024 14:36:50 +0100 Subject: [PATCH 05/10] fix: remove depreciated option --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 88eb96cd..e41b7310 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -140,7 +140,7 @@ skip_gitignore = true line-length = 99 [tool.ruff.lint] -extend-select = [ +select = [ "F", "E", "C", From e55f89f830dc232c3b3c03ca348a37579408b9fb Mon Sep 17 00:00:00 2001 From: esavary Date: Fri, 22 Mar 2024 15:03:49 +0100 Subject: [PATCH 06/10] Update pyproject.toml Co-authored-by: Oscar Esteban --- pyproject.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e41b7310..ba92cabb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -148,9 +148,7 @@ select = [ "B", ] ignore = [ - "N802", - "N806", - "E203", + "E203" ] [tool.ruff.lint.flake8-quotes] From 1c3566074f082ca6a02bf1b3e82bdf6ef7e11cc5 Mon Sep 17 00:00:00 2001 From: esavary Date: Fri, 22 Mar 2024 15:03:58 +0100 Subject: [PATCH 07/10] Update pyproject.toml Co-authored-by: Oscar Esteban --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index ba92cabb..e0285cf6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -158,6 +158,7 @@ inline-quotes = "double" "*/__init__.py" = ["F401"] "docs/conf.py" = ["E265"] "/^\\s*\\.\\. _.*?: http/" = ["E501"] +"src/eddymotion/estimator.py" = ["C901"] [tool.ruff.format] quote-style = "double" From 08f4c3dd4655c07863e6ad4743db4cab170ff5b5 Mon Sep 17 00:00:00 2001 From: esavary Date: Fri, 22 Mar 2024 15:59:52 +0100 Subject: [PATCH 08/10] fix: stack level in waring --- src/eddymotion/data/dmri.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/eddymotion/data/dmri.py b/src/eddymotion/data/dmri.py index 55d634a5..0f407bde 100644 --- a/src/eddymotion/data/dmri.py +++ b/src/eddymotion/data/dmri.py @@ -253,7 +253,8 @@ def load( if bvec_file and bval_file: warn( "Gradients table file and b-vec/val files are defined; " - "dismissing b-vec/val files." + "dismissing b-vec/val files.", + stacklevel=2 ) elif bvec_file and bval_file: grad = np.vstack( From 139fda20c6ef50d53d6aa7c587eb798cf734ccb1 Mon Sep 17 00:00:00 2001 From: esavary Date: Fri, 22 Mar 2024 16:07:24 +0100 Subject: [PATCH 09/10] fix: unnecessary tuple call --- src/eddymotion/model/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/eddymotion/model/base.py b/src/eddymotion/model/base.py index fe8aca40..5191024d 100644 --- a/src/eddymotion/model/base.py +++ b/src/eddymotion/model/base.py @@ -90,7 +90,7 @@ class BaseModel: "_models", "_datashape", ) - _modelargs = tuple() + _modelargs = () def __init__(self, gtab, S0=None, mask=None, b_max=None, **kwargs): """Base initialization.""" From 3adbf12071b7a0cff0320b4428a4ca4e698235db Mon Sep 17 00:00:00 2001 From: esavary Date: Fri, 22 Mar 2024 16:12:13 +0100 Subject: [PATCH 10/10] fix: unnecessary dict calls --- src/eddymotion/viz.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/eddymotion/viz.py b/src/eddymotion/viz.py index eeeaee88..84772258 100644 --- a/src/eddymotion/viz.py +++ b/src/eddymotion/viz.py @@ -343,7 +343,7 @@ def plot_carpet( segmentation_masked = segmentation_reshaped[segmentation_reshaped > 0] if segment_labels is not None: - segments = dict() + segments = {} labels = list(segment_labels.keys()) for label in labels: indices = np.array([], dtype=int) @@ -395,7 +395,7 @@ def get_segment_labels(filepath, keywords, delimiter=" ", index_position=0, labe 'Cerebral_Cortex': [3, 42], 'Ventricle': [4, 14, 15, 43, 72]} """ - segment_labels = dict() + segment_labels = {} with open(filepath, "r") as f: labels = f.read()