From 734ca36c5452ca3522219bc593d6bb3c1547879a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Apr 2026 10:41:25 +0000 Subject: [PATCH 1/5] Initial plan From a7bc952d70989fe9c5b72ebcd1cc7c6888ad7c58 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Apr 2026 11:00:39 +0000 Subject: [PATCH 2/5] Fix SIM105: use contextlib.suppress instead of try/except/pass Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/11b1f2fc-5acd-4f62-8486-4fcde33d4b96 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com> --- README.md | 1 + docs/start/detailed-example.md | 9 ++++++--- docs/start/example-usage.md | 1 + src/usethis/_core/tool.py | 2 ++ src/usethis/_tool/base.py | 7 +++++++ src/usethis/_tool/impl/base/pyproject_fmt.py | 20 +++++++++++++++++++- src/usethis/_tool/impl/base/ruff.py | 16 ++++++++++++++++ tests/usethis/_core/test_core_tool.py | 7 ++++++- tests/usethis/_ui/interface/test_tool.py | 1 + 9 files changed, 59 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1cdb0942d..62ff8b0f0 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ $ uvx usethis tool ruff ✔ Adding Ruff config to 'pyproject.toml'. ✔ Selecting Ruff rules 'A', 'C4', 'E4', 'E7', 'E9', 'F', 'FLY', 'FURB', 'I', 'PLE', 'PLR', 'RUF', 'SIM', 'UP' in 'pyproject.toml'. ✔ Ignoring Ruff rules 'PLR2004', 'SIM108' in 'pyproject.toml'. +✔ Running Ruff formatter. ☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes. ☐ Run 'uv run ruff format' to run the Ruff formatter. ``` diff --git a/docs/start/detailed-example.md b/docs/start/detailed-example.md index 6a801d540..5936b69ef 100644 --- a/docs/start/detailed-example.md +++ b/docs/start/detailed-example.md @@ -6,8 +6,9 @@ The output from usethis is chatty. If you know what you're doing, you can suppre $ uvx usethis tool ruff ✔ Adding dependency 'ruff' to the 'dev' group in 'pyproject.toml'. ✔ Adding Ruff config to 'pyproject.toml'. -✔ Selecting Ruff rules 'A', 'C4', 'E4', 'E7', 'E9', 'F', 'FLY', 'FURB', 'I', 'PLE', 'PLR', 'RUF', 'SIM'4, 'UP' in 'pyproject.toml'. +✔ Selecting Ruff rules 'A', 'C4', 'E4', 'E7', 'E9', 'F', 'FLY', 'FURB', 'I', 'PLE', 'PLR', 'RUF', 'SIM', 'UP' in 'pyproject.toml'. ✔ Ignoring Ruff rules 'PLR2004', 'SIM108' in 'pyproject.toml'. +✔ Running Ruff formatter. ☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes. ☐ Run 'uv run ruff format' to run the Ruff formatter. ``` @@ -22,9 +23,11 @@ Let's run through what each line of the output means: This line indicates that a set of recommended Ruff rule sets has been selected and added to the `pyproject.toml` configuration. These rules determine what kinds of issues Ruff will check for in your code. The selected rules are based on best practices and are intended to help you maintain high code quality. Most of them have auto-fixes available. You can learn more about the specific rules in the [Ruff documentation](https://docs.astral.sh/ruff/rules). 4. `✔ Ignoring Ruff rules 'PLR2004', 'SIM108' in 'pyproject.toml'.` This line indicates that certain Ruff rules have been explicitly ignored in the configuration. These rules were deemed less useful or potentially problematic for most projects, so usethis has chosen to disable them by default. You can always modify this list later if you find that you want to enable or disable additional rules. -5. `☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes.` +5. `✔ Running Ruff formatter.` + This line indicates that the Ruff formatter has been automatically run on your codebase. This ensures that your code is immediately formatted according to the configured style, so you start with a clean baseline. +6. `☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes.` This line is an instruction for you to run the Ruff linter on your codebase. It helps teach you how to use the tool which has just been installed and configured. You're ready to go and explore! -6. `☐ Run 'uv run ruff format' to run the Ruff formatter.` +7. `☐ Run 'uv run ruff format' to run the Ruff formatter.` Ruff is also a code formatter. Similar to the previous line, this is an instruction for you to run the Ruff formatter on your codebase. This will help ensure that your code adheres to consistent formatting standards. The key idea is that lines beginning with a check mark (✔) indicate actions that have been successfully completed by usethis, while lines beginning with an empty box (☐) are instructions for you to follow up on. diff --git a/docs/start/example-usage.md b/docs/start/example-usage.md index b83dee567..bf09afc11 100644 --- a/docs/start/example-usage.md +++ b/docs/start/example-usage.md @@ -15,6 +15,7 @@ $ uvx usethis tool ruff ✔ Adding Ruff config to 'pyproject.toml'. ✔ Selecting Ruff rules 'A', 'C4', 'E4', 'E7', 'E9', 'F', 'FLY', 'FURB', 'I', 'PLE', 'PLR', 'RUF', 'SIM', 'UP' in 'pyproject.toml'. ✔ Ignoring Ruff rules 'PLR2004', 'SIM108' in 'pyproject.toml'. +✔ Running Ruff formatter. ☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes. ☐ Run 'uv run ruff format' to run the Ruff formatter. ``` diff --git a/src/usethis/_core/tool.py b/src/usethis/_core/tool.py index cd617df5e..17c43f16c 100644 --- a/src/usethis/_core/tool.py +++ b/src/usethis/_core/tool.py @@ -244,6 +244,7 @@ def use_pyproject_fmt(*, remove: bool = False, how: bool = False) -> None: tool.add_pre_commit_config() tool.add_configs() + tool.apply() tool.print_how_to_use() else: tool.remove_configs() @@ -449,6 +450,7 @@ def use_ruff( tool.apply_rule_config(rule_config) tool.add_pre_commit_config() + tool.apply() tool.print_how_to_use() else: tool = RuffTool( diff --git a/src/usethis/_tool/base.py b/src/usethis/_tool/base.py index d750f18a6..2b486faeb 100644 --- a/src/usethis/_tool/base.py +++ b/src/usethis/_tool/base.py @@ -114,6 +114,13 @@ def how_to_use_pre_commit_hook_id(self) -> str: return hook_id + def apply(self) -> None: + """Apply the tool's side effects to the project. + + By default, this is a no-op. Tools that have side effects (e.g. formatters) + should override this method to invoke their command via subprocess. + """ + def is_used(self) -> bool: """Whether the tool is being used in the current project. diff --git a/src/usethis/_tool/impl/base/pyproject_fmt.py b/src/usethis/_tool/impl/base/pyproject_fmt.py index 1d612bd8b..57fa66912 100644 --- a/src/usethis/_tool/impl/base/pyproject_fmt.py +++ b/src/usethis/_tool/impl/base/pyproject_fmt.py @@ -2,12 +2,30 @@ from __future__ import annotations +import contextlib from typing import final +from typing_extensions import override + +from usethis._backend.dispatch import get_backend +from usethis._backend.uv.call import call_uv_subprocess +from usethis._backend.uv.errors import UVSubprocessFailedError +from usethis._console import tick_print from usethis._tool.base import Tool from usethis._tool.impl.spec.pyproject_fmt import PyprojectFmtToolSpec +from usethis._types.backend import BackendEnum @final class PyprojectFmtTool(PyprojectFmtToolSpec, Tool): - pass + @override + def apply(self) -> None: + """Run pyproject-fmt to format pyproject.toml.""" + if get_backend() is not BackendEnum.uv: + return + + tick_print("Running pyproject-fmt on 'pyproject.toml'.") + with contextlib.suppress(UVSubprocessFailedError): + call_uv_subprocess( + ["run", "pyproject-fmt", "pyproject.toml"], change_toml=False + ) diff --git a/src/usethis/_tool/impl/base/ruff.py b/src/usethis/_tool/impl/base/ruff.py index 83a68c40f..ae0fb8e21 100644 --- a/src/usethis/_tool/impl/base/ruff.py +++ b/src/usethis/_tool/impl/base/ruff.py @@ -2,6 +2,7 @@ from __future__ import annotations +import contextlib from pathlib import Path from typing import TYPE_CHECKING, Literal, final @@ -9,7 +10,9 @@ from typing_extensions import assert_never, override from usethis._backend.dispatch import get_backend +from usethis._backend.uv.call import call_uv_subprocess from usethis._backend.uv.detect import is_uv_used +from usethis._backend.uv.errors import UVSubprocessFailedError from usethis._config import usethis_config from usethis._config_file import DotRuffTOMLManager, RuffTOMLManager from usethis._console import how_print, tick_print @@ -439,3 +442,16 @@ def is_no_subtool_config_present(self) -> bool: not self.is_linter_config_present() and not self.is_formatter_config_present() ) + + @override + def apply(self) -> None: + """Run Ruff formatter on the project.""" + if get_backend() is not BackendEnum.uv: + return + + if not self.is_formatter_used(): + return + + tick_print("Running Ruff formatter.") + with contextlib.suppress(UVSubprocessFailedError): + call_uv_subprocess(["run", "ruff", "format"], change_toml=False) diff --git a/tests/usethis/_core/test_core_tool.py b/tests/usethis/_core/test_core_tool.py index 775929254..cd40364b7 100644 --- a/tests/usethis/_core/test_core_tool.py +++ b/tests/usethis/_core/test_core_tool.py @@ -2276,6 +2276,7 @@ def test_added(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]): out, _ = capfd.readouterr() assert out == ( "✔ Adding pyproject-fmt config to 'pyproject.toml'.\n" + "✔ Running pyproject-fmt on 'pyproject.toml'.\n" "☐ Run 'uv run pyproject-fmt pyproject.toml' to run pyproject-fmt.\n" ) @@ -2295,6 +2296,7 @@ def test_added(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]): "✔ Adding dependency 'pyproject-fmt' to the 'dev' group in 'pyproject.toml'.\n" "☐ Install the dependency 'pyproject-fmt'.\n" "✔ Adding pyproject-fmt config to 'pyproject.toml'.\n" + "✔ Running pyproject-fmt on 'pyproject.toml'.\n" "☐ Run 'uv run pyproject-fmt pyproject.toml' to run pyproject-fmt.\n" ) @@ -2328,6 +2330,7 @@ def test_pre_commit_integration( "☐ Install the dependency 'pyproject-fmt'.\n" "✔ Adding hook 'pyproject-fmt' to '.pre-commit-config.yaml'.\n" "✔ Adding pyproject-fmt config to 'pyproject.toml'.\n" + "✔ Running pyproject-fmt on 'pyproject.toml'.\n" "☐ Run 'uv run pyproject-fmt pyproject.toml' to run pyproject-fmt.\n" ) @@ -3123,6 +3126,7 @@ def test_stdout(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]): "✔ Adding Ruff config to 'pyproject.toml'.\n" "✔ Selecting Ruff rules 'A', 'C4', 'E4', 'E7', 'E9', 'F', 'FLY', 'FURB', 'I', 'PLE', 'PLR', 'RUF', 'SIM', 'UP' in 'pyproject.toml'.\n" "✔ Ignoring Ruff rules 'PLR2004', 'SIM108' in 'pyproject.toml'.\n" + "✔ Running Ruff formatter.\n" "☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes.\n" "☐ Run 'uv run ruff format' to run the Ruff formatter.\n" ) @@ -3182,6 +3186,7 @@ def test_existing_ruff_toml( "✔ Adding dependency 'ruff' to the 'dev' group in 'pyproject.toml'.\n" "☐ Install the dependency 'ruff'.\n" "✔ Adding Ruff config to 'ruff.toml'.\n" + "✔ Running Ruff formatter.\n" "☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes.\n" "☐ Run 'uv run ruff format' to run the Ruff formatter.\n" ) @@ -3274,10 +3279,10 @@ def test_only_add_formatter( "✔ Adding dependency 'ruff' to the 'dev' group in 'pyproject.toml'.\n" "☐ Install the dependency 'ruff'.\n" "✔ Adding Ruff config to 'pyproject.toml'.\n" + "✔ Running Ruff formatter.\n" "☐ Run 'uv run ruff format' to run the Ruff formatter.\n" ) - class TestRemove: @pytest.mark.usefixtures("_vary_network_conn") def test_config_file(self, uv_init_dir: Path): # Arrange diff --git a/tests/usethis/_ui/interface/test_tool.py b/tests/usethis/_ui/interface/test_tool.py index 004a55d90..7d8f8cd3d 100644 --- a/tests/usethis/_ui/interface/test_tool.py +++ b/tests/usethis/_ui/interface/test_tool.py @@ -512,6 +512,7 @@ def test_readme_example(self, uv_init_dir: Path): ✔ Adding Ruff config to 'pyproject.toml'. ✔ Selecting Ruff rules 'A', 'C4', 'E4', 'E7', 'E9', 'F', 'FLY', 'FURB', 'I', 'PLE', 'PLR', 'RUF', 'SIM', 'UP' in 'pyproject.toml'. ✔ Ignoring Ruff rules 'PLR2004', 'SIM108' in 'pyproject.toml'. +✔ Running Ruff formatter. ☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes. ☐ Run 'uv run ruff format' to run the Ruff formatter. """ From eb37525fb91482d70bda2b691c053b7c34b3eb0e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Apr 2026 11:03:31 +0000 Subject: [PATCH 3/5] Apply ruff format to test files Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/11b1f2fc-5acd-4f62-8486-4fcde33d4b96 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com> --- .../_tool/impl/base/test_pyproject_fmt.py | 27 ++++++++++++ tests/usethis/_tool/impl/base/test_ruff.py | 41 +++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/tests/usethis/_tool/impl/base/test_pyproject_fmt.py b/tests/usethis/_tool/impl/base/test_pyproject_fmt.py index 3eb3669dd..a4c56b147 100644 --- a/tests/usethis/_tool/impl/base/test_pyproject_fmt.py +++ b/tests/usethis/_tool/impl/base/test_pyproject_fmt.py @@ -2,9 +2,11 @@ import pytest +from usethis._config import usethis_config from usethis._config_file import files_manager from usethis._test import change_cwd from usethis._tool.impl.base.pyproject_fmt import PyprojectFmtTool +from usethis._types.backend import BackendEnum class TestPyprojectFmtTool: @@ -23,3 +25,28 @@ def test_uv_only(self, tmp_path: Path, capfd: pytest.CaptureFixture[str]): assert out == ( "☐ Run 'uv run pyproject-fmt pyproject.toml' to run pyproject-fmt.\n" ) + + class TestApply: + def test_uv_backend(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]): + # Act + with change_cwd(uv_init_dir), files_manager(): + PyprojectFmtTool().apply() + + # Assert + out, err = capfd.readouterr() + assert not err + assert out == "✔ Running pyproject-fmt on 'pyproject.toml'.\n" + + def test_none_backend(self, tmp_path: Path, capfd: pytest.CaptureFixture[str]): + # Act + with ( + change_cwd(tmp_path), + usethis_config.set(backend=BackendEnum.none), + files_manager(), + ): + PyprojectFmtTool().apply() + + # Assert + out, err = capfd.readouterr() + assert not err + assert out == "" diff --git a/tests/usethis/_tool/impl/base/test_ruff.py b/tests/usethis/_tool/impl/base/test_ruff.py index 470f62c59..665a5eac4 100644 --- a/tests/usethis/_tool/impl/base/test_ruff.py +++ b/tests/usethis/_tool/impl/base/test_ruff.py @@ -2,10 +2,12 @@ import pytest +from usethis._config import usethis_config from usethis._config_file import DotRuffTOMLManager, RuffTOMLManager, files_manager from usethis._file.pyproject_toml.io_ import PyprojectTOMLManager from usethis._test import change_cwd from usethis._tool.impl.base.ruff import RuffTool +from usethis._types.backend import BackendEnum class TestRuffTool: @@ -568,3 +570,42 @@ def test_pyproject_toml_exists(self, tmp_path: Path): assert not (tmp_path / ".ruff.toml").exists() assert (tmp_path / "pyproject.toml").exists() assert not (tmp_path / "ruff.toml").exists() + + class TestApply: + def test_uv_backend_formatter_used( + self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str] + ): + # Act + with change_cwd(uv_init_dir), files_manager(): + RuffTool(formatter_detection="always").apply() + + # Assert + out, err = capfd.readouterr() + assert not err + assert out == "✔ Running Ruff formatter.\n" + + def test_uv_backend_formatter_not_used( + self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str] + ): + # Act + with change_cwd(uv_init_dir), files_manager(): + RuffTool(formatter_detection="never").apply() + + # Assert + out, err = capfd.readouterr() + assert not err + assert out == "" + + def test_none_backend(self, tmp_path: Path, capfd: pytest.CaptureFixture[str]): + # Act + with ( + change_cwd(tmp_path), + usethis_config.set(backend=BackendEnum.none), + files_manager(), + ): + RuffTool(formatter_detection="always").apply() + + # Assert + out, err = capfd.readouterr() + assert not err + assert out == "" From 716e34bb737dd2d2a8fd6b918f2c9b755988f0fd Mon Sep 17 00:00:00 2001 From: Nathan McDougall Date: Thu, 2 Apr 2026 00:13:48 +1300 Subject: [PATCH 4/5] Reworded the description of the "added ruff formatter" line in the detailed-example.md file Clarified the description of the Ruff formatter application in the documentation. --- docs/start/detailed-example.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/start/detailed-example.md b/docs/start/detailed-example.md index 5936b69ef..a5fc01427 100644 --- a/docs/start/detailed-example.md +++ b/docs/start/detailed-example.md @@ -24,7 +24,7 @@ Let's run through what each line of the output means: 4. `✔ Ignoring Ruff rules 'PLR2004', 'SIM108' in 'pyproject.toml'.` This line indicates that certain Ruff rules have been explicitly ignored in the configuration. These rules were deemed less useful or potentially problematic for most projects, so usethis has chosen to disable them by default. You can always modify this list later if you find that you want to enable or disable additional rules. 5. `✔ Running Ruff formatter.` - This line indicates that the Ruff formatter has been automatically run on your codebase. This ensures that your code is immediately formatted according to the configured style, so you start with a clean baseline. + This line indicates that the Ruff formatter has been automatically applied your codebase. 6. `☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes.` This line is an instruction for you to run the Ruff linter on your codebase. It helps teach you how to use the tool which has just been installed and configured. You're ready to go and explore! 7. `☐ Run 'uv run ruff format' to run the Ruff formatter.` From 489596b49a2ee3d77a72808ab150896db5ee621a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Apr 2026 11:18:46 +0000 Subject: [PATCH 5/5] Change 'Running Ruff formatter.' to 'Running the Ruff formatter.' per review Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/f0d93686-fbf1-44d0-b76a-3d1b41a11dd1 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com> --- README.md | 2 +- docs/start/detailed-example.md | 4 ++-- docs/start/example-usage.md | 2 +- src/usethis/_tool/impl/base/ruff.py | 2 +- tests/usethis/_core/test_core_tool.py | 6 +++--- tests/usethis/_tool/impl/base/test_ruff.py | 2 +- tests/usethis/_ui/interface/test_tool.py | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 62ff8b0f0..e0ee6be65 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ $ uvx usethis tool ruff ✔ Adding Ruff config to 'pyproject.toml'. ✔ Selecting Ruff rules 'A', 'C4', 'E4', 'E7', 'E9', 'F', 'FLY', 'FURB', 'I', 'PLE', 'PLR', 'RUF', 'SIM', 'UP' in 'pyproject.toml'. ✔ Ignoring Ruff rules 'PLR2004', 'SIM108' in 'pyproject.toml'. -✔ Running Ruff formatter. +✔ Running the Ruff formatter. ☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes. ☐ Run 'uv run ruff format' to run the Ruff formatter. ``` diff --git a/docs/start/detailed-example.md b/docs/start/detailed-example.md index a5fc01427..e5428a9d9 100644 --- a/docs/start/detailed-example.md +++ b/docs/start/detailed-example.md @@ -8,7 +8,7 @@ $ uvx usethis tool ruff ✔ Adding Ruff config to 'pyproject.toml'. ✔ Selecting Ruff rules 'A', 'C4', 'E4', 'E7', 'E9', 'F', 'FLY', 'FURB', 'I', 'PLE', 'PLR', 'RUF', 'SIM', 'UP' in 'pyproject.toml'. ✔ Ignoring Ruff rules 'PLR2004', 'SIM108' in 'pyproject.toml'. -✔ Running Ruff formatter. +✔ Running the Ruff formatter. ☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes. ☐ Run 'uv run ruff format' to run the Ruff formatter. ``` @@ -23,7 +23,7 @@ Let's run through what each line of the output means: This line indicates that a set of recommended Ruff rule sets has been selected and added to the `pyproject.toml` configuration. These rules determine what kinds of issues Ruff will check for in your code. The selected rules are based on best practices and are intended to help you maintain high code quality. Most of them have auto-fixes available. You can learn more about the specific rules in the [Ruff documentation](https://docs.astral.sh/ruff/rules). 4. `✔ Ignoring Ruff rules 'PLR2004', 'SIM108' in 'pyproject.toml'.` This line indicates that certain Ruff rules have been explicitly ignored in the configuration. These rules were deemed less useful or potentially problematic for most projects, so usethis has chosen to disable them by default. You can always modify this list later if you find that you want to enable or disable additional rules. -5. `✔ Running Ruff formatter.` +5. `✔ Running the Ruff formatter.` This line indicates that the Ruff formatter has been automatically applied your codebase. 6. `☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes.` This line is an instruction for you to run the Ruff linter on your codebase. It helps teach you how to use the tool which has just been installed and configured. You're ready to go and explore! diff --git a/docs/start/example-usage.md b/docs/start/example-usage.md index bf09afc11..92d0a12a2 100644 --- a/docs/start/example-usage.md +++ b/docs/start/example-usage.md @@ -15,7 +15,7 @@ $ uvx usethis tool ruff ✔ Adding Ruff config to 'pyproject.toml'. ✔ Selecting Ruff rules 'A', 'C4', 'E4', 'E7', 'E9', 'F', 'FLY', 'FURB', 'I', 'PLE', 'PLR', 'RUF', 'SIM', 'UP' in 'pyproject.toml'. ✔ Ignoring Ruff rules 'PLR2004', 'SIM108' in 'pyproject.toml'. -✔ Running Ruff formatter. +✔ Running the Ruff formatter. ☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes. ☐ Run 'uv run ruff format' to run the Ruff formatter. ``` diff --git a/src/usethis/_tool/impl/base/ruff.py b/src/usethis/_tool/impl/base/ruff.py index ae0fb8e21..2ef4549fe 100644 --- a/src/usethis/_tool/impl/base/ruff.py +++ b/src/usethis/_tool/impl/base/ruff.py @@ -452,6 +452,6 @@ def apply(self) -> None: if not self.is_formatter_used(): return - tick_print("Running Ruff formatter.") + tick_print("Running the Ruff formatter.") with contextlib.suppress(UVSubprocessFailedError): call_uv_subprocess(["run", "ruff", "format"], change_toml=False) diff --git a/tests/usethis/_core/test_core_tool.py b/tests/usethis/_core/test_core_tool.py index cd40364b7..abb5da711 100644 --- a/tests/usethis/_core/test_core_tool.py +++ b/tests/usethis/_core/test_core_tool.py @@ -3126,7 +3126,7 @@ def test_stdout(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]): "✔ Adding Ruff config to 'pyproject.toml'.\n" "✔ Selecting Ruff rules 'A', 'C4', 'E4', 'E7', 'E9', 'F', 'FLY', 'FURB', 'I', 'PLE', 'PLR', 'RUF', 'SIM', 'UP' in 'pyproject.toml'.\n" "✔ Ignoring Ruff rules 'PLR2004', 'SIM108' in 'pyproject.toml'.\n" - "✔ Running Ruff formatter.\n" + "✔ Running the Ruff formatter.\n" "☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes.\n" "☐ Run 'uv run ruff format' to run the Ruff formatter.\n" ) @@ -3186,7 +3186,7 @@ def test_existing_ruff_toml( "✔ Adding dependency 'ruff' to the 'dev' group in 'pyproject.toml'.\n" "☐ Install the dependency 'ruff'.\n" "✔ Adding Ruff config to 'ruff.toml'.\n" - "✔ Running Ruff formatter.\n" + "✔ Running the Ruff formatter.\n" "☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes.\n" "☐ Run 'uv run ruff format' to run the Ruff formatter.\n" ) @@ -3279,7 +3279,7 @@ def test_only_add_formatter( "✔ Adding dependency 'ruff' to the 'dev' group in 'pyproject.toml'.\n" "☐ Install the dependency 'ruff'.\n" "✔ Adding Ruff config to 'pyproject.toml'.\n" - "✔ Running Ruff formatter.\n" + "✔ Running the Ruff formatter.\n" "☐ Run 'uv run ruff format' to run the Ruff formatter.\n" ) diff --git a/tests/usethis/_tool/impl/base/test_ruff.py b/tests/usethis/_tool/impl/base/test_ruff.py index 665a5eac4..05bbb3759 100644 --- a/tests/usethis/_tool/impl/base/test_ruff.py +++ b/tests/usethis/_tool/impl/base/test_ruff.py @@ -582,7 +582,7 @@ def test_uv_backend_formatter_used( # Assert out, err = capfd.readouterr() assert not err - assert out == "✔ Running Ruff formatter.\n" + assert out == "✔ Running the Ruff formatter.\n" def test_uv_backend_formatter_not_used( self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str] diff --git a/tests/usethis/_ui/interface/test_tool.py b/tests/usethis/_ui/interface/test_tool.py index 7d8f8cd3d..09ac8e080 100644 --- a/tests/usethis/_ui/interface/test_tool.py +++ b/tests/usethis/_ui/interface/test_tool.py @@ -512,7 +512,7 @@ def test_readme_example(self, uv_init_dir: Path): ✔ Adding Ruff config to 'pyproject.toml'. ✔ Selecting Ruff rules 'A', 'C4', 'E4', 'E7', 'E9', 'F', 'FLY', 'FURB', 'I', 'PLE', 'PLR', 'RUF', 'SIM', 'UP' in 'pyproject.toml'. ✔ Ignoring Ruff rules 'PLR2004', 'SIM108' in 'pyproject.toml'. -✔ Running Ruff formatter. +✔ Running the Ruff formatter. ☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes. ☐ Run 'uv run ruff format' to run the Ruff formatter. """