From 9b5a4d426d2a12caac6806eeb4d7f0d91cfb67c1 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Wed, 12 Mar 2025 14:03:50 +0100 Subject: [PATCH 1/8] Configure ruff docstring linting --- pyproject.toml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 8d534db5..dd9f673f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,3 +34,18 @@ pytest-cov = "^6.0.0" [build-system] build-backend = "poetry.core.masonry.api" requires = ["poetry-core"] + +[tool.ruff.lint] +select = [ + "D", + # imperative mood for all docstrings + "D401", +] + +ignore = [ + # no blank lines allowed after function docstring + "D202", +] + +[tool.ruff.lint.pydocstyle] +convention = "numpy" \ No newline at end of file From cb94e29e7f554727cf30f552ab2425f4c384741f Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Wed, 12 Mar 2025 14:10:09 +0100 Subject: [PATCH 2/8] Add a linting workflow --- .github/workflows/lint.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..b9ed3671 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,23 @@ +name: Lint 🕵 code ⚡ + +on: + push: + workflow_dispatch: + +jobs: + + lint: + name: Ruff ⚡🕵 + + runs-on: ubuntu-latest + + steps: + + - name: 📥 Checkout repo + uses: actions/checkout@v4 + + - name: Run Ruff ⚡ + uses: astral-sh/ruff-action@v3 + with: + args: check + src: "./src" From c8e482ae5fa18fc5e0034f99998d151b75d41b0f Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Wed, 12 Mar 2025 14:21:48 +0100 Subject: [PATCH 3/8] Rename workflow --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b9ed3671..0906c906 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: Lint 🕵 code ⚡ +name: 🔎 Lint code ⚡ on: push: From 8cd64c20b5753e6f21c57c74ea7791977f50d3cb Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Wed, 12 Mar 2025 14:22:23 +0100 Subject: [PATCH 4/8] Rename step, remove "src" argument --- .github/workflows/lint.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0906c906..c904bdca 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,8 +16,7 @@ jobs: - name: 📥 Checkout repo uses: actions/checkout@v4 - - name: Run Ruff ⚡ + - name: Run Ruff checks ⚡ uses: astral-sh/ruff-action@v3 with: args: check - src: "./src" From 6f40e6be661505484046560a2d5eb8bcf5b90ec4 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Wed, 12 Mar 2025 14:22:46 +0100 Subject: [PATCH 5/8] Enforce docstring summary on 1st line --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index dd9f673f..a421ce42 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,8 @@ requires = ["poetry-core"] [tool.ruff.lint] select = [ "D", + # summary lines have to be placed on the first physical line of the docstring + "D212", # imperative mood for all docstrings "D401", ] From 7defedc1a5b418f26c9a2a598eee3c62055fb4bf Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Wed, 12 Mar 2025 14:23:38 +0100 Subject: [PATCH 6/8] Summary line has to end in a punctuation mark --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index a421ce42..4adcc79a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,8 @@ select = [ "D212", # imperative mood for all docstrings "D401", + # summary line has to end in a punctuation mark + "D415", ] ignore = [ From 9361259f9dc36b4f8d9219a524e32ae8f55a9f06 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Wed, 12 Mar 2025 14:25:29 +0100 Subject: [PATCH 7/8] Require documentation for all function parameters --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 4adcc79a..204ea2ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,6 +44,8 @@ select = [ "D401", # summary line has to end in a punctuation mark "D415", + # require documentation for _all_ function parameters + "D417", ] ignore = [ From 918819e45d4f48817d8fa0aa02d2e299d78c3ad0 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter Date: Fri, 14 Mar 2025 00:30:28 +0100 Subject: [PATCH 8/8] Exclude interactive test scripts from linting --- pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 204ea2ae..0ab51dd3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,12 @@ pytest-cov = "^6.0.0" build-backend = "poetry.core.masonry.api" requires = ["poetry-core"] + [tool.ruff.lint] +exclude = [ + "tests/interactive-imagej/*" +] + select = [ "D", # summary lines have to be placed on the first physical line of the docstring @@ -53,5 +58,6 @@ ignore = [ "D202", ] + [tool.ruff.lint.pydocstyle] convention = "numpy" \ No newline at end of file