[Breaking Change] Add usethis hook command and --hook/--no-hook to usethis init#1454
Conversation
- Create _toolset/hook.py wrapping use_pre_commit() - Create _ui/interface/hook.py CLI interface - Register `usethis hook` command in app.py - Replace --pre-commit/--no-pre-commit with --hook/--no-hook in init - Update .importlinter, docs/cli/overview.md, and README.md - Add test_hook.py tests and update test_init.py Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com> Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/5e55d87a-8269-437d-8ff1-abea260f5a4a
usethis hook command and --hook/--no-hook to usethis init
usethis hook command and --hook/--no-hook to usethis initusethis hook command and --hook/--no-hook to usethis init
|
This is a breaking change because it renames the |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Adds a new high-level usethis hook CLI command (wrapping pre-commit) and renames the usethis init flag from --pre-commit/--no-pre-commit to --hook/--no-hook, aligning git hook management with other “Manage Tooling” commands.
Changes:
- Introduces
usethis hookUI + toolset entrypoint and registers it in the Typer app. - Renames
usethis init’s pre-commit option to--hook/--no-hookand rewires init to call the toolset hook function. - Updates overview/README docs and import-linter layer contract; adds CLI interface tests for
hook.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/usethis/_ui/interface/test_init.py | Updates init CLI tests for the renamed --hook option and new output message. |
| tests/usethis/_ui/interface/test_hook.py | Adds new CLI tests for usethis hook add/how/remove/backend behaviors. |
| src/usethis/_ui/interface/init.py | Renames init option and routes hook setup via use_hook_framework(). |
| src/usethis/_ui/interface/hook.py | New CLI entrypoint implementing usethis hook with standard tool flags. |
| src/usethis/_ui/app.py | Registers the new top-level hook command in the Typer app. |
| src/usethis/_toolset/hook.py | Adds toolset wrapper use_hook_framework() (currently delegates to use_pre_commit()). |
| docs/cli/overview.md | Adds usethis hook to the CLI overview list. |
| README.md | Adds usethis hook to the README CLI command list. |
| .importlinter | Adds hook to the ui_interface layers contract. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - [`usethis arch`](https://usethis.readthedocs.io/en/stable/cli/reference#usethis-arch) — Add/Configure recommended architecture analysis tools (namely, [Import Linter](https://import-linter.readthedocs.io/en/stable/)). | ||
| - [`usethis doc`](https://usethis.readthedocs.io/en/stable/cli/reference#usethis-doc) — Add/Configure recommended documentation tools (namely, [MkDocs](https://www.mkdocs.org/)). | ||
| - [`usethis format`](https://usethis.readthedocs.io/en/stable/cli/reference#usethis-format) — Add/Configure recommended formatters (namely, [Ruff](https://docs.astral.sh/ruff/formatter/) and [pyproject-fmt](https://pyproject-fmt.readthedocs.io/en/latest/)). | ||
| - [`usethis hook`](https://usethis.readthedocs.io/en/stable/cli/reference#usethis-hook) — Add/Configure a recommended git hook framework (namely, [pre-commit](https://github.com/pre-commit/pre-commit)). |
There was a problem hiding this comment.
README links to .../cli/reference#usethis-hook, but the in-repo CLI reference doc (docs/cli/reference.md) currently has no usethis hook section/anchor and still documents --pre-commit/--no-pre-commit for usethis init. Until the reference is updated, this README link is likely to 404/mislead.
| - [`usethis hook`](https://usethis.readthedocs.io/en/stable/cli/reference#usethis-hook) — Add/Configure a recommended git hook framework (namely, [pre-commit](https://github.com/pre-commit/pre-commit)). | |
| - [`usethis hook`](https://usethis.readthedocs.io/en/stable/cli/reference) — Add/Configure a recommended git hook framework (namely, [pre-commit](https://github.com/pre-commit/pre-commit)). |
There was a problem hiding this comment.
@copilot likewise, please update reference.md to ensure this hyperlink is valid
There was a problem hiding this comment.
Updated docs/cli/reference.md in ebd433b — added a new ## usethis hook section (with anchor #usethis-hook) and renamed --pre-commit to --hook under usethis init.
There was a problem hiding this comment.
Done in ebd433b — reference.md now has the #usethis-hook anchor.
| - [`usethis arch`](https://usethis.readthedocs.io/en/stable/cli/reference#usethis-arch) — Add/Configure recommended architecture analysis tools (namely, [Import Linter](https://import-linter.readthedocs.io/en/stable/)). | ||
| - [`usethis doc`](https://usethis.readthedocs.io/en/stable/cli/reference#usethis-doc) — Add/Configure recommended documentation tools (namely, [MkDocs](https://www.mkdocs.org/)). | ||
| - [`usethis format`](https://usethis.readthedocs.io/en/stable/cli/reference#usethis-format) — Add/Configure recommended formatters (namely, [Ruff](https://docs.astral.sh/ruff/formatter/) and [pyproject-fmt](https://pyproject-fmt.readthedocs.io/en/latest/)). | ||
| - [`usethis hook`](https://usethis.readthedocs.io/en/stable/cli/reference#usethis-hook) — Add/Configure a recommended git hook framework (namely, [pre-commit](https://github.com/pre-commit/pre-commit)). |
There was a problem hiding this comment.
@copilot likewise, please update reference.md to ensure this hyperlink is valid
…-pre-commit to --hook Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com> Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/fdd7c3d5-e514-44f7-a799-5ec619a872f5
Higher-level interface for managing git hooks, analogous to
usethis lint,usethis typecheck, etc. Usespre-commitas the underlying framework for now.Changes
usethis hookcommand — top-level command under "Manage Tooling" with standard--remove,--how,--offline,--frozen,--backendoptions_toolset/hook.py: wrapsuse_pre_commit()_ui/interface/hook.py: CLI interfaceapp.pyusethis initflag rename —--pre-commit/--no-pre-commit→--hook/--no-hook(default:False)use_hook_framework()from the toolset layer instead of importinguse_pre_commitdirectly from_corehookadded to.importlinterui_interfacecontractusethis hookadded todocs/cli/overview.md,docs/cli/reference.md, andREADME.mddocs/cli/reference.md: new## usethis hooksection added and--pre-commitrenamed to--hookunderusethis initUsage
Original prompt
usethis hookor similar #1004📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.