Skip to content

Split usethis._tool.impl into spec/ and base/ submodules#1357

Closed
Copilot wants to merge 6 commits intomainfrom
copilot/split-tool-impl-layers
Closed

Split usethis._tool.impl into spec/ and base/ submodules#1357
Copilot wants to merge 6 commits intomainfrom
copilot/split-tool-impl-layers

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 11, 2026

Each module in usethis._tool.impl contained both a *ToolSpec class (static metadata, deps, pre-commit config) and a *Tool class (runtime behavior). This PR splits them into parallel submodules and removes the original flat modules.

Changes

  • New impl/spec/ — one file per tool, containing only *ToolSpec subclasses and their supporting constants/helpers (e.g. _RUFF_VERSION, _importlinter_warn_no_packages_found)
  • New impl/base/ — one file per tool, containing only *Tool subclasses; each imports its *ToolSpec from spec/
  • Original impl/*.py flat modules removed — all imports across the codebase updated to use the new spec/ or base/ paths directly
  • .importlinter updated — new contracts for usethis._tool.impl, usethis._tool.impl.spec, and usethis._tool.impl.base reflecting the clean layered architecture (base strictly above spec)

New import paths

# Tool classes (runtime behavior)
from usethis._tool.impl.base.ruff import RuffTool

# ToolSpec classes (static metadata/config)
from usethis._tool.impl.spec.ruff import RuffToolSpec
Original prompt

This section details on the original issue you should resolve

<issue_title>Split the usethis._tool.impl layer into usethis._tool.impl.spec and usethis._tool.impl.base layers</issue_title>
<issue_description>Current dir structure looks like this:

src\usethis_tool\impl
src\usethis_tool\impl_init_.py
src\usethis_tool\impl\codespell.py
src\usethis_tool\impl\coverage_py.py
src\usethis_tool\impl\deptry.py
src\usethis_tool\impl\import_linter.py
src\usethis_tool\impl\mkdocs.py
src\usethis_tool\impl\pre_commit.py
src\usethis_tool\impl\pyproject_fmt.py
src\usethis_tool\impl\pyproject_toml.py
src\usethis_tool\impl\pytest.py
src\usethis_tool\impl\requirements_txt.py
src\usethis_tool\impl\ruff.py

Each module contains the implementation for a ToolSpec and a Tool subclass.

We should create a submodule in the impl module for spec and base separately with parallel submodule structures.

This helps us work toward #1311 </issue_description>

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


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits March 11, 2026 00:39
- Create src/usethis/_tool/impl/spec/ with *ToolSpec classes
- Create src/usethis/_tool/impl/base/ with *Tool classes
- Update original impl/*.py files as re-export shims for backward compat
- Update circular lazy imports (pytest/coverage_py) to point to base/
- Update base/pyproject_toml.py to import from base/ directly
- Fix test_pytest.py monkeypatch to target new base.pytest module

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Import SetupCFGManager from usethis._file.setup_cfg.io_ in base/codespell.py
- Normalize 'to avoid circularity' comment style to end with period

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot AI changed the title [WIP] Split the usethis._tool.impl layer into spec and base layers Split usethis._tool.impl into spec/ and base/ submodules Mar 11, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 11, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing copilot/split-tool-impl-layers (d10ccca) with main (7274253)

Open in CodSpeed

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 11, 2026

@nathanjmcdougall
Copy link
Copy Markdown
Collaborator

@copilot I have added a skill called usethis-python-module-layout-modify. You should adhere to it, since you have changed the module structure

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
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.

Split the usethis._tool.impl layer into usethis._tool.impl.spec and usethis._tool.impl.base layers

2 participants