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..e0285cf6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -136,18 +136,33 @@ 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] +select = [ + "F", + "E", + "C", + "W", + "B", +] +ignore = [ + "E203" ] +[tool.ruff.lint.flake8-quotes] +inline-quotes = "double" + +[tool.ruff.lint.extend-per-file-ignores] +"*/__init__.py" = ["F401"] +"docs/conf.py" = ["E265"] +"/^\\s*\\.\\. _.*?: http/" = ["E501"] +"src/eddymotion/estimator.py" = ["C901"] + +[tool.ruff.format] +quote-style = "double" + [tool.pytest.ini_options] pythonpath = "src/ test/" norecursedirs = [".*", "_*"] 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( 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.""" 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()