Add Tool.default_command() to eliminate duplication in CI steps and help messages#1088
Merged
nathanjmcdougall merged 8 commits intomainfrom Nov 5, 2025
Merged
Conversation
…classes Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Create Tool.default_command method to avoid duplication
Add Tool.default_command() to eliminate duplication in CI steps and help messages
Nov 5, 2025
Closed
nathanjmcdougall
requested changes
Nov 5, 2025
…ning None Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
nathanjmcdougall
approved these changes
Nov 5, 2025
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
CodSpeed Performance ReportMerging #1088 will not alter performanceComparing Summary
Footnotes |
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.
The
get_bitbucket_steps()methods across tool implementations contained significant duplication, repeating the same command strings used in help messages. This PR introducesTool.default_command()to define commands once and enables a defaultget_bitbucket_steps()implementation.Changes
Core Protocol Method
default_command() -> strtoToolprotocol that returns backend-dependent command strings"uv run <tool> [args]"when uv backend is active withuv.lockpresent"<tool> [args]"for none backend or uv without lock fileNoDefaultToolCommandexception by default for tools without commands (instead of returningNone)Custom Exception
NoDefaultToolCommandexception insrc/usethis/errors.pyfor tools that don't have associated commandsget_bitbucket_steps()implementation uses try-except to handle tools without commandsDefault Implementation
get_bitbucket_steps()implementation in baseToolclass that usesdefault_command()Tool Updates
Implemented
default_command()in 5 tools:"codespell""pyproject-fmt pyproject.toml""deptry {src_dir}"(dynamic)"lint-imports""pytest"Note: RuffTool was intentionally excluded as it doesn't have a single default command (has separate linter and formatter commands).
Refactored
print_how_to_use()methods to usedefault_command()instead of duplicating command strings.Code Reduction
Removed ~160 lines of duplicated
get_bitbucket_steps()implementations from simple tools (CodespellTool, PyprojectFmtTool, DeptryTool, ImportLinterTool) that now inherit the default implementation.Example
Before:
After:
Tool.default_commandmethod #1077Original prompt
Tool.default_commandmethod #1077✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.