Skip to content

test: enable mypy checks for test_agent.py - #12761

Merged
anakin87 merged 1 commit into
deepset-ai:mainfrom
yavuz-yilmaz:test/agent-mypy
Sep 17, 2026
Merged

anakin87 merged 1 commit into
deepset-ai:mainfrom
yavuz-yilmaz:test/agent-mypy

Conversation

@yavuz-yilmaz

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

test/components/agents/test_agent.py is not included in the default mypy target and currently reports 82 errors when checked directly. Add it to the types target and resolve those errors:

  • Complete missing parameter and return annotations, and explicitly type mixed reply/tool lists.
  • Narrow deserialized tools to Tool / ComponentTool and check for the socket attributes added by @component.
  • Replace dynamically attached warm-up tracking fields with test-local Tool / Toolset subclasses. Their overrides still call super().warm_up() before recording success.
  • Use monkeypatch.setattr for mock methods and retain references to the mocks for the existing call/await assertions.

The only added suppression is a documented # type: ignore[arg-type] where the negative test deliberately passes a bare string to _select_tools. Its expected TypeError and message assertion are preserved. Mypy settings are unchanged.

How did you test it?

Local environment: Windows, Python 3.13.12, Hatch 1.18.0; mypy targets Python 3.12 as configured by the project.

  • Targeted mypy: 82 errors before, zero after.
  • hatch run test:types: 542 source files clean.
  • hatch run test:unit test/components/agents/ --no-cov: 345 passed, 6 deselected.
  • hatch run test:integration test/components/agents/test_agent.py::TestAgentUserPromptInPipeline: 2 passed.
  • hatch run fmt-check test/components/agents/test_agent.py pyproject.toml: passed.
  • Applicable pre-commit hooks on both changed files, including during commit: passed.
  • git diff --check: passed.

A separate Codex review repeated these checks, reproduced the original 82 errors using mypy's --shadow-file, and compared warm-up behavior before and after. Live API tests and the full repository unit suite were not run.

Notes for the reviewer

Changes are limited to the test file and its mypy target entry. Existing test cases and assertions are retained; production code is unchanged.

No release note is included for this test-only change; the current release-note workflow exempts test: commits.

AI disclosure: This PR was generated with OpenAI Codex. The complete patch was reviewed and tested locally, including the separate Codex review described above.

Checklist

  • Read the contributor guidelines, code of conduct, and applicable AGENTS.md instructions.
  • Linked the tracking issue and documented this increment and its validation here.
  • Preserved and ran the existing tests; no new behavior or public docstring changes are needed.
  • Used a conventional test: title.
  • Explained the typing changes and the deliberate invalid-input suppression.
  • Checked the test-only release-note exemption.
  • Ran the applicable pre-commit hooks.

@yavuz-yilmaz
yavuz-yilmaz requested a review from a team as a code owner September 15, 2026 18:55
@yavuz-yilmaz
yavuz-yilmaz requested review from anakin87 and removed request for a team September 15, 2026 18:55
@CLAassistant

CLAassistant commented Sep 15, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@vercel

vercel Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

@yavuz-yilmaz is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@anakin87 anakin87 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thank you

@anakin87
anakin87 enabled auto-merge (squash) September 17, 2026 10:33
@anakin87
anakin87 merged commit 91fdc44 into deepset-ai:main Sep 17, 2026
24 of 25 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

This PR does not seem to contain any modification to coverable code.

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.

3 participants