Skip to content

test: enable mypy typing checks for the whole test folder - #12930

Merged
bogdankostic merged 2 commits into
deepset-ai:mainfrom
ShousenZHANG:test/type-check-whole-test-folder
Sep 25, 2026
Merged

bogdankostic merged 2 commits into
deepset-ai:mainfrom
ShousenZHANG:test/type-check-whole-test-folder

Conversation

@ShousenZHANG

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

Replaces the hand-maintained path list in the types target with {args:haystack test} and drops the # TODO We want to eventually type the whole test folder. All the old list still skipped was test/conftest.py plus test/__init__.py, test/components/agents/__init__.py and test/hooks/__init__.py, which contain only the license header. The unchecked directories in the #10396 list (classifiers/, connectors/, readers/, tools/, websearch/) no longer exist on main.

Baseline on those four files was 3 errors, all in conftest.py. No suppressions.

  • 2 no-untyped-def on request_blocker: monkeypatch: pytest.MonkeyPatch and -> None, next to the request: pytest.FixtureRequest it already had.
  • 1 attr-defined. spying_tracer did tracer.is_content_tracing_enabled = True on a SpyingTracer. That flag is an attribute of the global ProxyTracer (haystack/tracing/tracer.py:118), which is where the base Span.set_content_tag reads it (:65), so setting it on the spying instance never reached anything — and SpyingSpan.set_content_tag (test/tracing/utils.py:31) overrides that method and records unconditionally anyway. The line is removed rather than pointed at the global tracer: that would flip a process-wide flag for every test using the fixture, which test/core/pipeline/test_tracing.py already does where it needs to, scoped through monkeypatch.

How did you test it?

  • Before: mypy on the four files -> 3 errors. After: hatch run test:types checks 550 source files (546 before), with only the pre-existing error below.
  • pytest on test/tracing, test/core/pipeline/test_tracing.py and the three modules that use spying_tracer (test_agent.py, test_llm_evaluator.py, test_llm_document_content_extractor.py) -> 237 passed. Full unit suite -> 6497 passed, 47 skipped.
  • hatch run fmt-check -> clean, 7139 files.
  • One mypy error and two unit tests still fail on my machine and all three reproduce identically on a clean main checkout: test_openai_responses_conversion.py:1017 (local openai 3.3.1 predates the name field on ResponseFunctionCallArgumentsDoneEvent; CI resolves a newer one) and the spam.csv case of test_from_file_path_guess_mime_type (Windows mime registry). Neither is touched by this change.

No release note: test and dev-tooling config only, which AGENTS.md excludes from the release-note requirement.


This PR was written with AI assistance.

Replace the hand-maintained path list in the `types` target with
`{args:haystack test}`. The only tracked files the list still skipped were
`test/conftest.py` and three license-header-only `__init__.py` files.

Fix the 3 errors in `conftest.py`:

- annotate `request_blocker`'s `monkeypatch` parameter and return type
- drop `tracer.is_content_tracing_enabled = True` from `spying_tracer`: the
  flag lives on the global `ProxyTracer`, not on `SpyingTracer`, and
  `SpyingSpan.set_content_tag` records unconditionally, so the assignment
  never had an effect

Part of #10396.
Copilot AI lite review requested due to automatic review settings September 24, 2026 14:55
@ShousenZHANG
ShousenZHANG requested a review from a team as a code owner September 24, 2026 14:55
@ShousenZHANG
ShousenZHANG requested review from bogdankostic and removed request for a team September 24, 2026 14:55
@vercel

vercel Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/core/pipeline
  pipeline.py
Project Total  

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

@bogdankostic bogdankostic self-assigned this Sep 25, 2026

@bogdankostic bogdankostic left a comment

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.

Looks good, thanks @ShousenZHANG!

@bogdankostic
bogdankostic merged commit bf679e3 into deepset-ai:main Sep 25, 2026
23 of 24 checks passed
@bogdankostic bogdankostic mentioned this pull request Sep 25, 2026
27 of 38 tasks
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