Split usethis._tool.impl into impl/spec and impl/base submodules#1373
Split usethis._tool.impl into impl/spec and impl/base submodules#1373nathanjmcdougall merged 5 commits intomainfrom
usethis._tool.impl into impl/spec and impl/base submodules#1373Conversation
Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
…nces Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
usethis._tool.impl into impl/spec and impl/base submodules
|
@copilot I have updated the |
…tructure Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Done in 320fbd9 — moved all 11 test files from |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR refactors the usethis._tool.impl layer by splitting each tool’s implementation into two parallel subpackages: impl/spec for declarative ToolSpec metadata and impl/base for runtime Tool behavior, updating all internal imports and tests accordingly.
Changes:
- Introduces
src/usethis/_tool/impl/spec/*modules containingToolSpecsubclasses (metadata, deps, pre-commit config, preferred config file selection). - Introduces/updates
src/usethis/_tool/impl/base/*modules containingToolsubclasses (runtime behavior like config management and how-to-use output) that depend on their correspondingspecmodules. - Updates import paths across core/toolset/UI code, tests, and
.importlintercontracts to reflect the new structure.
Reviewed changes
Copilot reviewed 46 out of 48 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| .importlinter | Updates import-linter contracts to model impl as base above spec, plus adds dedicated contracts for each subpackage. |
| src/usethis/_core/ci.py | Updates tool imports to the new usethis._tool.impl.base.* paths. |
| src/usethis/_core/docstyle.py | Updates Ruff tool import path to impl.base. |
| src/usethis/_core/list.py | Updates Ruff tool import path to impl.base. |
| src/usethis/_core/rule.py | Updates Deptry/Ruff tool import paths to impl.base. |
| src/usethis/_core/tool.py | Updates all tool imports to impl.base. |
| src/usethis/tool/all.py | Updates ALL_TOOLS imports to impl.base tool classes. |
| src/usethis/_tool/impl/base/codespell.py | Moves runtime CodespellTool behavior into impl/base and imports CodespellToolSpec from impl/spec. |
| src/usethis/_tool/impl/base/coverage_py.py | Moves runtime CoveragePyTool behavior into impl/base and imports CoveragePyToolSpec from impl/spec; updates circular imports to new paths. |
| src/usethis/_tool/impl/base/deptry.py | Moves runtime DeptryTool behavior into impl/base and imports DeptryToolSpec from impl/spec. |
| src/usethis/_tool/impl/base/import_linter.py | Moves runtime ImportLinterTool behavior into impl/base and imports ImportLinterToolSpec from impl/spec; removes spec-only helpers. |
| src/usethis/_tool/impl/base/mkdocs.py | Moves runtime MkDocsTool behavior into impl/base and imports MkDocsToolSpec from impl/spec. |
| src/usethis/_tool/impl/base/pre_commit.py | Moves runtime PreCommitTool behavior into impl/base and imports PreCommitToolSpec from impl/spec. |
| src/usethis/_tool/impl/base/pyproject_fmt.py | Moves runtime PyprojectFmtTool behavior into impl/base and imports PyprojectFmtToolSpec from impl/spec. |
| src/usethis/_tool/impl/base/pyproject_toml.py | Updates tool aggregation imports to impl.base.* and imports PyprojectTOMLToolSpec from impl/spec. |
| src/usethis/_tool/impl/base/pytest.py | Moves runtime PytestTool behavior into impl/base and imports PytestToolSpec from impl/spec; updates circular imports to new paths. |
| src/usethis/_tool/impl/base/requirements_txt.py | Moves runtime RequirementsTxtTool behavior into impl/base and imports RequirementsTxtToolSpec from impl/spec. |
| src/usethis/_tool/impl/base/ruff.py | Removes embedded RuffToolSpec and imports it from impl/spec, keeping runtime logic in impl/base. |
| src/usethis/_tool/impl/pyproject_fmt.py | Deletes the old combined (spec+base) module in favor of split impl/spec + impl/base. |
| src/usethis/_tool/impl/spec/codespell.py | Adds CodespellToolSpec module (metadata/deps/pre-commit config). |
| src/usethis/_tool/impl/spec/coverage_py.py | Adds CoveragePyToolSpec module (metadata + preferred config file selection). |
| src/usethis/_tool/impl/spec/deptry.py | Adds DeptryToolSpec module (metadata/deps/pre-commit config). |
| src/usethis/_tool/impl/spec/import_linter.py | Adds ImportLinterToolSpec module (metadata/deps/pre-commit config + layered-architecture helpers + warning helper). |
| src/usethis/_tool/impl/spec/mkdocs.py | Adds MkDocsToolSpec module (metadata/doc deps/preferred config file). |
| src/usethis/_tool/impl/spec/pre_commit.py | Adds PreCommitToolSpec module (metadata/deps/pre-commit config + version constant). |
| src/usethis/_tool/impl/spec/pyproject_fmt.py | Adds PyprojectFmtToolSpec module (metadata/deps/pre-commit config + version constant). |
| src/usethis/_tool/impl/spec/pyproject_toml.py | Adds PyprojectTOMLToolSpec module (metadata). |
| src/usethis/_tool/impl/spec/pytest.py | Adds PytestToolSpec module (metadata/raw cmd/preferred config file + RuleConfig). |
| src/usethis/_tool/impl/spec/requirements_txt.py | Removes runtime RequirementsTxtTool from spec module (leaving spec-only behavior). |
| src/usethis/_tool/impl/spec/ruff.py | Adds RuffToolSpec module (metadata/dev deps/preferred config file). |
| src/usethis/toolset/format.py | Updates PyprojectTOMLTool import path to impl.base. |
| src/usethis/_ui/interface/readme.py | Updates PreCommitTool/RuffTool import paths to impl.base. |
| tests/conftest.py | Updates import of _importlinter_warn_no_packages_found to impl.spec.import_linter. |
| tests/usethis/_core/test_core_tool.py | Updates imports: Ruff from impl.base, _SYNC_WITH_UV_VERSION from impl.spec.pre_commit. |
| tests/usethis/_core/test_rule.py | Updates Deptry/Ruff imports to impl.base. |
| tests/usethis/_tool/impl/base/test_codespell.py | Updates CodespellTool import to impl.base. |
| tests/usethis/_tool/impl/base/test_coverage_py.py | Updates CoveragePyTool import to impl.base. |
| tests/usethis/_tool/impl/base/test_deptry.py | Updates DeptryTool import to impl.base. |
| tests/usethis/_tool/impl/base/test_import_linter.py | Updates ImportLinterTool import to impl.base. |
| tests/usethis/_tool/impl/base/test_mkdocs.py | Updates MkDocsTool import to impl.base. |
| tests/usethis/_tool/impl/base/test_pre_commit.py | Updates PreCommitTool import to impl.base. |
| tests/usethis/_tool/impl/base/test_pyproject_fmt.py | Updates PyprojectFmtTool import to impl.base. |
| tests/usethis/_tool/impl/base/test_pyproject_toml.py | Updates PyprojectTOMLTool import to impl.base. |
| tests/usethis/_tool/impl/base/test_pytest.py | Updates module/class imports and monkeypatch target to impl.base.pytest. |
| tests/usethis/_tool/impl/base/test_requirements_txt.py | Updates RequirementsTxtTool import to impl.base. |
| tests/usethis/_tool/impl/base/test_ruff.py | Updates RuffTool import to impl.base. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
The flat
usethis._tool.implmodule mixedToolSpecsubclasses (declarative metadata) andToolsubclasses (runtime behaviour) in the same files. This splits them into parallel submodule structures to separate concerns.Structure
Each tool now has two dedicated modules:
usethis._tool.impl.spec.*—ToolSpecsubclasses:meta,dev_deps,pre_commit_config,preferred_file_manager, etc.usethis._tool.impl.base.*—Toolsubclasses:config_spec,print_how_to_use,get_bitbucket_steps,selected_rules, etc.The test directory mirrors the
srcstructure:Notable decisions
test_deps()moved tobase/forpytestandcoverage_py: these methods call.is_used()on siblingToolinstances, making them runtime behaviour rather than declarative spec. Moving them tobase/eliminates thespec → baseimport cycle and enforces the cleanbase → specdependency direction.tool_implcontract is replaced with three —tool_impl(baseabovespec),tool_impl_base, andtool_impl_spec— each with the same internal layer ordering as before._core/,_tool/all_.py,_toolset/,_ui/, tests) updated to the new paths.tests/usethis/_tool/impl/test_*.pyfiles moved totests/usethis/_tool/impl/base/to match thesrclayout.Original prompt
usethis._tool.impllayer intousethis._tool.impl.specandusethis._tool.impl.baselayers #1356✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.