Skip to content

Introduce ToolSpec and ToolMeta abstractions to keep tool classes more accessible#1342

Merged
nathanjmcdougall merged 7 commits intomainfrom
1315-consider-an-architectural-distinction-between-aspects-inherent-to-a-tool-versus-aspects-varying-by-repo
Mar 5, 2026
Merged

Introduce ToolSpec and ToolMeta abstractions to keep tool classes more accessible#1342
nathanjmcdougall merged 7 commits intomainfrom
1315-consider-an-architectural-distinction-between-aspects-inherent-to-a-tool-versus-aspects-varying-by-repo

Conversation

@nathanjmcdougall
Copy link
Copy Markdown
Collaborator

@nathanjmcdougall nathanjmcdougall commented Mar 5, 2026

Resolves #1315 and resolves #1316

@nathanjmcdougall nathanjmcdougall requested a review from Copilot March 5, 2026 03:07
@nathanjmcdougall nathanjmcdougall changed the title 1315 consider an architectural distinction between aspects inherent to a tool versus aspects varying by repo Introduce ToolSpec and ToolMeta abstractions to keep tool classes more accessible Mar 5, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 5, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing 1315-consider-an-architectural-distinction-between-aspects-inherent-to-a-tool-versus-aspects-varying-by-repo (9a0d4ed) with main (1c8cc4d)

Open in CodSpeed

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 5, 2026

Codecov Report

❌ Patch coverage is 95.58233% with 11 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/usethis/_tool/impl/ruff.py 82.69% 9 Missing ⚠️
src/usethis/_tool/impl/requirements_txt.py 90.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 / ToolSpec and updates tool implementations to use meta, 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 -a instead of --all-files across 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.

@nathanjmcdougall nathanjmcdougall merged commit c4b28e4 into main Mar 5, 2026
19 checks passed
@nathanjmcdougall nathanjmcdougall deleted the 1315-consider-an-architectural-distinction-between-aspects-inherent-to-a-tool-versus-aspects-varying-by-repo branch March 5, 2026 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants