Skip to content

Rename _HOOK_ORDER to HOOK_GROUPS as list of lists#1749

Merged
nathanjmcdougall merged 2 commits intomainfrom
copilot/update-hook-order-to-hook-groups
Apr 1, 2026
Merged

Rename _HOOK_ORDER to HOOK_GROUPS as list of lists#1749
nathanjmcdougall merged 2 commits intomainfrom
copilot/update-hook-order-to-hook-groups

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

_HOOK_ORDER was a flat list of hook names with no way to express which hooks can safely run in parallel (relevant for prek priority groups). Replace it with a HOOK_GROUPS: list[list[str]] where each inner list is a group of hooks at the same priority level.

Structure

HOOK_GROUPS: list[list[str]] = [
    ["sync-with-uv", "validate-pyproject", "uv-export", "pyproject-fmt", "ruff", "ruff-check"],
    ["ruff-format"],
    ["ty", "deptry", "lint_imports", "import-linter", "tach", "codespell"],
]
  • Group 0: Setup, validation, formatting, lint+fix
  • Group 1: Code formatting (depends on group 0, e.g. ruff-format after ruff-check)
  • Group 2: Read-only checkers (safe to run in parallel)

Flattening produces the same ordering as the original _HOOK_ORDER.

Changes

  • hooks.py: Replace _HOOK_ORDER with HOOK_GROUPS, flatten inline in add_repo() for index-based ordering
  • test_core_tool.py: Update import and flatten before membership check
  • test_hooks.py: Add TestHookGroups (structure validation, no duplicates, non-empty), update comments

…f lists

Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/cfa13f2e-4c66-40aa-beda-bac181bc2603

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot AI changed the title [WIP] Update _HOOK_ORDER to be more sophisticated with groups Rename _HOOK_ORDER to HOOK_GROUPS as list of lists Apr 1, 2026
Copilot AI requested a review from nathanjmcdougall April 1, 2026 19:41
@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review April 1, 2026 19:47
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 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 Apr 1, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing copilot/update-hook-order-to-hook-groups (8ef3517) with main (e41efcf)

Open in CodSpeed

@nathanjmcdougall nathanjmcdougall merged commit 60f5655 into main Apr 1, 2026
20 checks passed
@nathanjmcdougall nathanjmcdougall deleted the copilot/update-hook-order-to-hook-groups branch April 1, 2026 20:01
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.

Make _HOOK_ORDER more sophisticated

2 participants