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 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 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 -%} 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 %}