Title: Add `apply()` method to `Tool` for running formatters on use by Copilot · Pull Request #1714 · usethis-python/usethis-python · GitHub
Open Graph Title: Add `apply()` method to `Tool` for running formatters on use by Copilot · Pull Request #1714 · usethis-python/usethis-python
X Title: Add `apply()` method to `Tool` for running formatters on use by Copilot · Pull Request #1714 · usethis-python/usethis-python
Description: Formatters like pyproject-fmt and ruff format should run automatically when added to a project via use, so the codebase is immediately formatted to the configured style. Changes Tool.apply() base method — No-op by default on the Tool Protocol class. Formatters override to invoke their CLI. PyprojectFmtTool.apply() — Runs uv run pyproject-fmt pyproject.toml with tick_print message. Guards on uv backend; suppresses subprocess errors (tool may not yet be installed in frozen mode). RuffTool.apply() — Runs uv run ruff format (not linter auto-fixes). Additionally guards on is_formatter_used(). use_pyproject_fmt() / use_ruff() — Call tool.apply() after add_configs(), before print_how_to_use(). Tests — Updated 6 existing output assertions, added 5 new unit tests covering both backends and formatter detection states. 100% coverage on new code. Docs — Updated README and detailed-example to reflect the new ✔ Running the Ruff formatter. / ✔ Running pyproject-fmt on 'pyproject.toml'. output lines. # Pattern for formatter tools: @override def apply(self) -> None: if get_backend() is not BackendEnum.uv: return tick_print("Running the Ruff formatter.") with contextlib.suppress(UVSubprocessFailedError): call_uv_subprocess(["run", "ruff", "format"], change_toml=False)
Open Graph Description: Formatters like pyproject-fmt and ruff format should run automatically when added to a project via use, so the codebase is immediately formatted to the configured style. Changes Tool.apply() base ...
X Description: Formatters like pyproject-fmt and ruff format should run automatically when added to a project via use, so the codebase is immediately formatted to the configured style. Changes Tool.apply() base ...
Opengraph URL: https://github.com/usethis-python/usethis-python/pull/1714
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:0798f583-1d28-02b4-37c4-113e453d0761 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8CA4:6474B:E88839:140BA9B:6A4DECF2 |
| html-safe-nonce | 2252bbd98dc2e1a706e97f709ada1d9e561267366af308ba7fd51eef723bab52 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Q0E0OjY0NzRCOkU4ODgzOToxNDBCQTlCOjZBNERFQ0YyIiwidmlzaXRvcl9pZCI6IjM4OTY1NzQ5MTQ2MTQ2NTIxNDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a1c75d6e0c78b0e99060004e801c0dbf4be0b83452572f28a46c2fbc15a39d29 |
| hovercard-subject-tag | pull_request:3476521412 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/usethis-python/usethis-python/pull/1714/files |
| twitter:image | https://avatars.githubusercontent.com/in/1143301?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/in/1143301?s=400&v=4 |
| og:image:alt | Formatters like pyproject-fmt and ruff format should run automatically when added to a project via use, so the codebase is immediately formatted to the configured style. Changes Tool.apply() base ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/usethis-python/usethis-python git https://github.com/usethis-python/usethis-python.git |
| octolytics-dimension-user_id | 216362695 |
| octolytics-dimension-user_login | usethis-python |
| octolytics-dimension-repository_id | 842189705 |
| octolytics-dimension-repository_nwo | usethis-python/usethis-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 842189705 |
| octolytics-dimension-repository_network_root_nwo | usethis-python/usethis-python |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1d344bdb7547fe6bca17a59bb2b8aac3dc9532a0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width