Skip to content

Add --no-hook flag to all usethis tool subcommands#1558

Merged
nathanjmcdougall merged 11 commits intomainfrom
copilot/add-no-hook-flag-to-tools
Mar 27, 2026
Merged

Add --no-hook flag to all usethis tool subcommands#1558
nathanjmcdougall merged 11 commits intomainfrom
copilot/add-no-hook-flag-to-tools

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

  • Add no_hook_opt shared option to src/usethis/_ui/options.py
  • Add --no-hook flag to all tool commands in src/usethis/_ui/interface/tool.py
  • Add disable_pre_commit check to remove_pre_commit_repo_configs() in src/usethis/_tool/base.py
  • Update docs/cli/reference.md to document the new --no-hook flag
  • Add tests for the --no-hook flag (consolidated into TestCodespell and TestRuff classes)
  • Run static checks (prek, basedpyright) - all pass
  • Run CodeQL security scan - no alerts
Original prompt

This section details on the original issue you should resolve

<issue_title>Include a --no-hook flag for all tools</issue_title>
<issue_description>Motivation
Not all tools use pre-commit, but it makes sense to keep the interface consistent.

Basically in some cases we might not want to add a tool as a pre-commit, even though it's possible. So we can add this flag to basically treat pre-commit as being unused for the purposes of adding the tool.

If removing the tool, then --no-hook can ignore the pre-commit configuration and not remove from that.

Summary of desired enhancement
Include a --no-hook flag for all tools in the usethis tool subcommand set.
</issue_description>

Comments on the Issue (you are @copilot in this section)

@nathanjmcdougall Might want to avoid hard-coding the name `pre-commit` in interfaces, better might be `--no-hook`. See #1004

⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

Copilot AI and others added 3 commits March 26, 2026 00:05
Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/6b5576e1-3848-496b-838f-646d2976a563
- Add no_hook_opt shared option in options.py
- Add --no-hook parameter to all 12 tool commands in tool.py
- Pass no_hook through to usethis_config.set(disable_pre_commit=no_hook)
- Add disable_pre_commit check to remove_pre_commit_repo_configs() in base.py
- Update docs/cli/reference.md with the new flag
- Add tests for --no-hook with add/remove scenarios

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/6b5576e1-3848-496b-838f-646d2976a563
- Move get_hook_ids import to top-level in test file
- Add assertion that ruff config was actually applied when using --no-hook

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/6b5576e1-3848-496b-838f-646d2976a563
Copilot AI changed the title [WIP] Add --no-hook flag for all tools in usethis Add --no-hook flag to all usethis tool subcommands Mar 26, 2026
Copilot AI requested a review from nathanjmcdougall March 26, 2026 00:16
@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review March 26, 2026 22:23
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 26, 2026

Merging this PR will degrade performance by 8.36%

❌ 2 (👁 2) regressed benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
👁 Simulation test_several_tools_add_and_remove 836.8 ms 864.2 ms -3.17%
👁 Simulation test_help_flag 37 ms 40.4 ms -8.36%

Comparing copilot/add-no-hook-flag-to-tools (e71e9a5) with main (13f5208)

Open in CodSpeed

Consolidate tests from the standalone TestNoHook class into their
respective tool test classes for better organization.

Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/bdf911da-fd3b-4192-bb4b-305306de2fd1

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
@nathanjmcdougall nathanjmcdougall merged commit 06a5fed into main Mar 27, 2026
20 checks passed
@nathanjmcdougall nathanjmcdougall deleted the copilot/add-no-hook-flag-to-tools branch March 27, 2026 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include a --no-hook flag for all tools

2 participants