Repository navigation
test: enable mypy typing checks for test/components/converters - #12754
Merged
julian-risch merged 1 commit intoSep 15, 2026
Merged
Conversation
Replaces the four per-entry converter paths on the `types` script with the directory itself and fixes the 55 errors that surfaces. Every other token on that line is unchanged. Most of it is one cause. A list literal is invariant, so `sources = ["a.json"]` infers `list[str]`, which is not a `list[str | Path | ByteStream]`; annotating the variable settles it. That accounts for 32 of the annotations, across eight modules. Annotating the `test_files_path` fixture then turned eight more `list[Any]` lists into `list[Path]`, which needed the same treatment. The rest: - `test_files_path: Path` on nine tests, matching `test_textfile_to_document.py`, plus `caplog: pytest.LogCaptureFixture` and one `Literal["markdown", "plain"]`. - Narrowed rather than suppressed: `assert content is not None` before `in content`, `isinstance(document, Document)` / `isinstance(attachment, ByteStream)` in the MSG test, and `isinstance(deserialized_adapter, OutputAdapter)` after `get_component`, which is typed as returning the protocol. The last one follows `test/core/pipeline/test_pipeline_base.py`. - `os.path.basename` now reads a `str` local instead of the union element. Seven suppressions, in two groups. Three are `__haystack_output__` / `__haystack_input__`, injected by `@component` where mypy cannot see them, and `test/core/component/test_component.py` already suppresses those the same way. Four are tests whose subject is the type error: `sources=[123]`, `char_margin=None` in `test_arg_is_none`, and `link_format="invalid"` twice, each asserting the component rejects it. Part of #10396.
ShousenZHANG
requested review from
julian-risch
and
a lite review from Copilot
and removed request for
a team and
Copilot
September 15, 2026 02:41
Contributor
|
@ShousenZHANG is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
7 tasks done
julian-risch
approved these changes
Sep 15, 2026
julian-risch
left a comment
Member
There was a problem hiding this comment.
LGTM! Thank you for another PR @ShousenZHANG !
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.
Related Issues
converters/image/), test: enable mypy typing checks for test/hooks/compaction #12749, test: enable mypy typing checks for the test/hooks root modules #12711 and test: enable mypy typing checks for test/hooks/budget #12710Proposed Changes:
Replaces the four per-entry converter paths on the
typestarget with the directory itself, sotest/components/converters/is covered as a whole and that line gets four tokens shorter. Every other token on it is unchanged. Baseline was 55 errors across 9 modules.Most of it is one cause. A list literal is invariant, so
sources = ["a.json"]inferslist[str], which is not alist[str | Path | ByteStream]; annotating the variable settles it. Annotating thetest_files_pathfixture then turned eight morelist[Any]lists intolist[Path], which needed the same treatment — 32 annotations in total, across eight modules, all of the same shape.The rest:
test_files_path: Pathon nine tests, matchingtest_textfile_to_document.pyin the same directory, pluscaplog: pytest.LogCaptureFixtureand oneLiteral["markdown", "plain"].assert content is not Nonebeforein content;isinstance(document, Document)andisinstance(attachment, ByteStream)in the MSG test, where the lists hold a union; andisinstance(deserialized_adapter, OutputAdapter)afterget_component, which is typed as returning the protocol — followingtest/core/pipeline/test_pipeline_base.py. That last one also makes the assertion check that deserialization returns the concrete component.os.path.basenamereads astrlocal instead of a union element, rather than casting at the call.Seven suppressions, in two groups. Three are
__haystack_output__/__haystack_input__, injected by@componentwhere mypy cannot see them;test/core/component/test_component.pyalready suppresses those the same way. Four are tests whose subject is the type error:sources=[123],char_margin=Noneintest_arg_is_none, andlink_format="invalid"twice, each asserting the component rejects the value.How did you test it?
mypyontest/components/converters/-> 55 errors. After: zero, 22 source files checked.pytest test/components/converters/-> 289 passed.ruff check/ruff format --checkover the repo -> clean, 6804 files.check_imports.py-> 262 modules.maincheckout, so none is from this change: two unit tests and one mypy error from a newer localopenaithan the tests expect plus the Windows mime registry, and the twotest_multi_file_converter.pyintegration tests, which are downstream of that same mime mismatch.With this,
test/components/converters/is fully covered.test/components/agents/(106 errors) and the five modules attest/root (18) are what remain outside the target.No release note: test-only, which AGENTS.md excludes from the release-note requirement.
This PR was written with AI assistance.