Introduce ToolSpec and ToolMeta abstractions to keep tool classes more accessible#1342
Merged
nathanjmcdougall merged 7 commits intomainfrom Mar 5, 2026
Conversation
ToolSpec and ToolMeta abstractions to keep tool classes more accessible
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the tool architecture to separate static tool metadata from repo-dependent behavior, helping avoid import cycles and clarifying which parts of a tool are “inherent” vs “project-specific” (resolves #1315 and #1316).
Changes:
- Introduces
ToolMeta/ToolSpecand updates tool implementations to usemeta,raw_cmd, and renamed APIs (dev_deps,config_spec,pre_commit_config,selected_rules,ignored_rules, etc.). - Standardizes “run all files” pre-commit invocations to use
-ainstead of--all-filesacross UI messaging, tests, and CI/pipeline fixtures. - Bumps embedded tool/version constants (e.g., Ruff + pyproject-fmt) and updates uv fallback version.
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/usethis/_tool/base.py |
Adds ToolMeta/ToolSpec, provides default behaviors, and renames core tool APIs used across the codebase. |
src/usethis/_integrations/pre_commit/cmd_.py |
Introduces a shared pre_commit_raw_cmd string for how-to-use command construction. |
src/usethis/_core/tool.py |
Switches rule-config integration to use tool.rule_config and updates calls to renamed rule APIs. |
src/usethis/_tool/impl/ruff.py |
Splits Ruff into RuffToolSpec + RuffTool, updates config/pre-commit/rule APIs, and tweaks how-to-use strings. |
src/usethis/_tool/impl/pytest.py |
Splits pytest into PytestToolSpec + PytestTool, migrates deps/config APIs, and uses how_to_use_cmd(). |
src/usethis/_tool/impl/coverage_py.py |
Splits coverage.py into spec + tool and migrates config/deps APIs. |
src/usethis/_tool/impl/codespell.py |
Splits Codespell into spec + tool; moves default command logic to raw_cmd()/how_to_use_cmd(). |
src/usethis/_tool/impl/import_linter.py |
Splits Import Linter into spec + tool; moves pre-commit config and standardizes how-to-use printing. |
src/usethis/_tool/impl/deptry.py |
Splits deptry into spec + tool and migrates config/pre-commit/rule APIs. |
src/usethis/_tool/impl/pre_commit.py |
Splits pre-commit into spec + tool; standardizes “run hooks” messaging/Bitbucket step commands to -a. |
src/usethis/_tool/impl/mkdocs.py |
Splits MkDocs into spec + tool and migrates deps/config APIs. |
src/usethis/_tool/impl/pyproject_fmt.py |
Splits pyproject-fmt into spec + tool and migrates deps/pre-commit/config APIs. |
src/usethis/_tool/impl/pyproject_toml.py |
Splits pyproject.toml “tool” into spec + tool and migrates managed-files metadata to ToolMeta. |
src/usethis/_tool/impl/requirements_txt.py |
Splits requirements.txt into spec + tool; moves pre-commit config into spec. |
src/usethis/_backend/uv/version.py |
Updates uv fallback version constant. |
tests/usethis/_tool/test_base.py |
Updates tool test doubles and assertions to new ToolMeta + renamed APIs. |
tests/usethis/_tool/impl/test_ruff.py |
Updates Ruff tests to use renamed rule/pre-commit APIs. |
tests/usethis/_tool/impl/test_pytest.py |
Updates pytest tests to use how_to_use_cmd(). |
tests/usethis/_tool/impl/test_pyproject_toml.py |
Updates to dev_deps() API. |
tests/usethis/_tool/impl/test_pyproject_fmt.py |
Updates to pre_commit_config() API. |
tests/usethis/_tool/impl/test_pre_commit.py |
Updates to pre_commit_config() API. |
tests/usethis/_tool/impl/test_import_linter.py |
Updates messages to -a and config API naming changes. |
tests/usethis/_tool/impl/test_deptry.py |
Updates to renamed config/rule/pre-commit APIs and removes is_managed_rule test coverage. |
tests/usethis/_tool/impl/test_codespell.py |
Updates messages and APIs (how_to_use_cmd, dev_deps, pre_commit_config). |
tests/usethis/_core/test_rule.py |
Updates Ruff/deptry rule assertions to renamed rule APIs. |
tests/usethis/_core/test_core_tool.py |
Updates expected UI output and rule assertions to renamed APIs and -a messaging. |
tests/usethis/_core/test_core_ci.py |
Updates expected Bitbucket pipeline script to use -a. |
tests/usethis/_ui/interface/test_tool.py |
Updates subprocess invocations and UI output expectations to -a. |
tests/usethis/_ui/interface/test_init.py |
Updates init output expectations to -a. |
tests/usethis/_ui/interface/maximal_bitbucket_pipelines_uv.yml |
Updates fixture pipeline commands to -a. |
.github/workflows/ci.yml |
Changes CI to run prek run -a instead of --all-files. |
.github/copilot-instructions.md |
Updates documented pre-commit check invocation to prek run -a. |
You can also share your feedback on Copilot code review. Take the survey.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #1315 and resolves #1316