Skip to content

chore: Add type checking to test/tools#11284

Open
maxdswain wants to merge 1 commit intodeepset-ai:mainfrom
maxdswain:tools-tests-type-checking
Open

chore: Add type checking to test/tools#11284
maxdswain wants to merge 1 commit intodeepset-ai:mainfrom
maxdswain:tools-tests-type-checking

Conversation

@maxdswain
Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

This PR extends type checking to test/tools.

How did you test it?

Re-ran tests - unit, integration and type checkng.

Notes for the reviewer

I didn't want to add WarmupTrackingTool or other classes created just for tests to ToolsType, so I used # type: ignore for these situations.

I modified haystack/tools/__init__.py expanding the ToolsType to include list[ComponentTool] & list[PipelineTool], I think this was the right thing to do but I'm not sure on this.

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

@maxdswain maxdswain requested a review from a team as a code owner May 10, 2026 13:53
@maxdswain maxdswain requested review from sjrl and removed request for a team May 10, 2026 13:53
@vercel
Copy link
Copy Markdown

vercel Bot commented May 10, 2026

@maxdswain is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/core/pipeline
  async_pipeline.py
  haystack/tools
  __init__.py
  from_function.py
Project Total  

This report was generated by python-coverage-comment-action

# - list[PipelineTool]: List of PipelineTool objects
# - Toolset: Single Toolset (not in a list)
ToolsType = list[Tool] | list[Toolset] | list[Tool | Toolset] | Toolset
ToolsType = list[Tool] | list[Toolset] | list[Tool | Toolset] | list[ComponentTool] | list[PipelineTool] | Toolset
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to explicitly include ComponentTool and PipelineTool since they both inherit from Tool.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anakin87 do the changes to this file (addition of the overload) fix the typing issues you were seeing?

]

toolset = SearchableToolset(catalog=[LazyToolset()] + eager_tools)
toolset = SearchableToolset(catalog=[LazyToolset()] + eager_tools) # type: ignore[arg-type]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave a dev comment explaining why we are ignoring this. Also it seems odd we are ignoring this I think I would expect this to pass. Which arg is throwing the type error?


assert not tool.was_warmed_up
warm_up_tools([tool])
warm_up_tools([tool]) # type: ignore[arg-type]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain what error is being raised here? I'd expect this to pass since WarmupTrackingTool inherits from Tool

assert not tool2.was_warmed_up

warm_up_tools([toolset])
warm_up_tools([toolset]) # type: ignore[arg-type]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjrl sjrl self-assigned this May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants