Skip to content

Add @final to all methods in ToolSpec and Tool implementations#1432

Merged
nathanjmcdougall merged 4 commits intomainfrom
copilot/add-final-to-tool-methods
Mar 20, 2026
Merged

Add @final to all methods in ToolSpec and Tool implementations#1432
nathanjmcdougall merged 4 commits intomainfrom
copilot/add-final-to-tool-methods

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 20, 2026

  • Add @final decorator to all methods in all ToolSpec implementation classes (11 spec files in impl/spec/)
  • Add @final decorator to all methods in all Tool implementation classes (11 base files in impl/base/)
  • Handle special cases: @property combined with @final, @staticmethod combined with @final, __init__ methods
  • Run static checks to validate type-checking compliance (prek + basedpyright: 0 errors)
  • Run targeted tests to ensure no regressions (100 passed, 11 skipped)
  • Document @final requirement in CONTRIBUTING.md "Adding a new tool" section
  • Code review and security scan (no issues)
Original prompt

This section details on the original issue you should resolve

<issue_title>Add @final to all methods in all ToolSpec and Tool implementations</issue_title>
<issue_description>typing.final

To ensure we don't over-ride methods defined in a ToolSpec implementation in the Tool implementations subclass.

Was a bit worried about this in the #1430 </issue_description>

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


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/ac4205d5-03bc-4d8d-951a-bdf5271a13a7
Copilot AI changed the title [WIP] Add @final to all methods in ToolSpec and Tool implementations Add @final to all methods in ToolSpec and Tool implementations Mar 20, 2026
Copilot AI requested a review from nathanjmcdougall March 20, 2026 18:32
@nathanjmcdougall
Copy link
Copy Markdown
Collaborator

@copilot please recommend/explain this in the CONTRIBUTING.md section on how to implement tools

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 20, 2026

@copilot please recommend/explain this in the CONTRIBUTING.md section on how to implement tools

Added documentation in commit a2e3c8e. The "Create the Tool and ToolSpec subclasses" section now explains the @final requirement for both ToolSpec and Tool methods, including decorator ordering for properties and a code example.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 20, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing copilot/add-final-to-tool-methods (6ef3702) with main (2ae04db)

Open in CodSpeed

Removed example code for marking methods with `@typing.final` in `ToolSpec` subclass.

Also remove outdated advice regarding URL (now in `ToolMeta`
@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review March 20, 2026 20:28
@nathanjmcdougall nathanjmcdougall merged commit 9305f2e into main Mar 20, 2026
19 checks passed
@nathanjmcdougall nathanjmcdougall deleted the copilot/add-final-to-tool-methods branch March 20, 2026 20:29
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 2026

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!

Copilot AI added a commit that referenced this pull request Mar 25, 2026
…t submodule contracts

Closes #1432

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/385f0827-605c-428f-8947-960907d3c5a9
nathanjmcdougall added a commit that referenced this pull request Mar 25, 2026
* Initial plan

* fix: only exclude _version from top-level Import Linter contracts, not submodule contracts

Closes #1432

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/385f0827-605c-428f-8947-960907d3c5a9

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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.

Add @final to all methods in all ToolSpec and Tool implementations

2 participants