Skip to content

Use ALL_TOOLS as single source of truth for canonical tool ordering#1793

Merged
nathanjmcdougall merged 6 commits into
mainfrom
copilot/consider-using-all-tools-for-ordering
Apr 4, 2026
Merged

Use ALL_TOOLS as single source of truth for canonical tool ordering#1793
nathanjmcdougall merged 6 commits into
mainfrom
copilot/consider-using-all-tools-for-ordering

Conversation

Copilot AI commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Tool ordering was defined redundantly in three separate places (ALL_TOOLS, OTHER_TOOLS in pyproject_toml.py, ALL_TOOL_COMMANDS in tool.py), allowing them to drift. ALL_TOOL_COMMANDS already had a bug: pyproject.toml appeared before pyproject-fmt, contradicting alphabetical order in ALL_TOOLS.

Changes

  • _tool/impl/spec/all_.py (new) – introduces ALL_TOOL_SPECS, a canonical list of all ToolSpec instances in alphabetical order, mirroring ALL_TOOLS but at the spec layer. This avoids a circular import: _tool.impl.base can import from _tool.impl.spec, but not from _tool.all_.

  • pyproject_toml.py – replaces the duplicated _OTHER_TOOLS list with a direct use of ALL_TOOL_SPECS from the new spec registry, filtering out PyprojectTOMLToolSpec inline and using is_likely_used(tool_spec) in place of tool.is_used(). All sibling base-Tool imports are removed.

  • .importlinter – adds all_ as the top layer in the tool_impl_spec contract to accommodate the new module.

  • tool.py – replaces the hardcoded ALL_TOOL_COMMANDS with a derived computation:

    def _get_all_tool_commands() -> list[str]:
        from usethis._tool.all_ import ALL_TOOLS
        return [tool.name.lower().replace(" ", "-") for tool in ALL_TOOLS]
    
    ALL_TOOL_COMMANDS: list[str] = _get_all_tool_commands()

    This fixes the pyproject.toml/pyproject-fmt ordering bug as a side effect.

  • all_.pyOTHER_TOOLS is removed entirely. It had no remaining consumers in source code after the ALL_TOOL_SPECS refactor, and its only test was a circular self-validating assertion.

  • Teststest_tool_matches_command upgraded from set equality to list equality (enforces order); TestAllToolSpecs.test_in_sync_with_all_tools guards that ALL_TOOL_SPECS stays in sync with ALL_TOOLS.

Copilot AI changed the title [WIP] Consider using ALL_TOOLS for canonical tool ordering Use ALL_TOOLS as single source of truth for canonical tool ordering Apr 4, 2026
Copilot AI requested a review from nathanjmcdougall April 4, 2026 00:24
Comment thread src/usethis/_tool/impl/base/pyproject_toml.py Outdated
Copilot AI requested a review from nathanjmcdougall April 4, 2026 08:49
@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review April 4, 2026 09:11
Comment thread src/usethis/_tool/all_.py Outdated
@codecov

codecov Bot commented Apr 4, 2026

Copy link
Copy Markdown

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

codspeed-hq Bot commented Apr 4, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing copilot/consider-using-all-tools-for-ordering (e50cb6e) with main (c51c40a)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (4282401) during the generation of this report, so c51c40a was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

…CS refactor

Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/f9182353-f655-4e0f-ac44-f175b44a686d

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
@nathanjmcdougall nathanjmcdougall merged commit 7c45f33 into main Apr 4, 2026
20 checks passed
@nathanjmcdougall nathanjmcdougall deleted the copilot/consider-using-all-tools-for-ordering branch April 4, 2026 17:23
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.

Consider using ALL_TOOLS as the one-source-of-truth for canonical tool ordering

2 participants