From 286be72b15003c742e5db075079501a3806eb455 Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Mon, 8 Sep 2025 12:08:29 +0200 Subject: [PATCH 1/3] replace yapf reference with instruction to use 'ruff format' --- template/{% if AddDevDoc %}README.dev.md{% endif %}.jinja | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/template/{% if AddDevDoc %}README.dev.md{% endif %}.jinja b/template/{% if AddDevDoc %}README.dev.md{% endif %}.jinja index 11cb34a5..ebcb751a 100644 --- a/template/{% if AddDevDoc %}README.dev.md{% endif %}.jinja +++ b/template/{% if AddDevDoc %}README.dev.md{% endif %}.jinja @@ -65,7 +65,7 @@ coverage report {%- if AddLinting -%} ## Running linters locally -For linting and sorting imports we will use [ruff](https://beta.ruff.rs/docs/). Running the linters requires an +For linting and sorting imports we will use [ruff](https://docs.astral.sh/ruff/). Running the linters requires an activated virtual environment with the development tools installed. ```shell @@ -76,7 +76,11 @@ ruff check . ruff check . --fix ``` -To fix readability of your code style you can use [yapf](https://github.com/google/yapf). +It also provides a command to fix readability of your code style: + +```shell +ruff format . +``` {%- endif -%} {%- if AddPreCommit -%} From ab31a4baac9aa6cdc5bc13de20dee052e32c0fee Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Mon, 8 Sep 2025 12:38:25 +0200 Subject: [PATCH 2/3] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d260b95b..ec7d3e4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ ### Changed +* Recommend `ruff format` instead of `yapf` for fixing code style readability [#695](https://github.com/NLeSC/python-template/pull/695) + ### Removed ## 0.6.1 From 72ac6879dd1f6b7520cb30b0b6fa095a2fe2b4e3 Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Mon, 17 Nov 2025 11:02:08 +0100 Subject: [PATCH 3/3] consistently use ruff .; ignore rule COM812 --- template/pyproject.toml.jinja | 1 + .../{% if AddPreCommit %}.githooks{% endif %}/pre-commit | 4 ++-- .../{% if AddGitHubActionBuild %}build.yml{% endif %}.jinja | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/template/pyproject.toml.jinja b/template/pyproject.toml.jinja index 868ff711..1a854574 100644 --- a/template/pyproject.toml.jinja +++ b/template/pyproject.toml.jinja @@ -135,6 +135,7 @@ ignore = [ "FIX001", # Resolve FIXMEs "FIX002", # Resolve TODOs "B028", # No explicit `stacklevel` keyword argument found in warning + "COM812", # Trailing commas are taken care of by `ruff format` # No docstrings required in the following cases "D100", # Missing module docstring "D104", # Missing public package docstring diff --git a/template/{% if AddPreCommit %}.githooks{% endif %}/pre-commit b/template/{% if AddPreCommit %}.githooks{% endif %}/pre-commit index c4bc8dd3..ccd92dd1 100755 --- a/template/{% if AddPreCommit %}.githooks{% endif %}/pre-commit +++ b/template/{% if AddPreCommit %}.githooks{% endif %}/pre-commit @@ -6,8 +6,8 @@ echo "Script $0 triggered ..." echo "Starting ruff analysis..." # quietly run ruff -ruff check --fix -ruff format +ruff check --fix . +ruff format . # use return code to abort commit if necessary if [ $? != "0" ]; then diff --git a/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddGitHubActionBuild %}build.yml{% endif %}.jinja b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddGitHubActionBuild %}build.yml{% endif %}.jinja index 3d6926ab..29ad2602 100644 --- a/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddGitHubActionBuild %}build.yml{% endif %}.jinja +++ b/template/{% if HasWorkflows %}.github{% endif %}/workflows/{% if AddGitHubActionBuild %}build.yml{% endif %}.jinja @@ -61,8 +61,8 @@ jobs: python -m pip install .[dev,publishing] - name: Check style against standards using ruff run: | - ruff check - ruff format --check + ruff check . + ruff format --check . {%- endif %} {%- if AddTyping %} @@ -82,4 +82,4 @@ jobs: - name: Run {{ SelectTypeChecker }} run: | {{ SelectTypeChecker }} -{%- endif %} \ No newline at end of file +{%- endif %}