Repository navigation
test: enable mypy typing checks for test/components/converters/image - #12750
Merged
anakin87 merged 1 commit intoSep 14, 2026
Merged
Conversation
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
anakin87
requested changes
Sep 14, 2026
anakin87
left a comment
Member
There was a problem hiding this comment.
Please fix conflicts in pyproject.toml
Adds `test/components/converters/image/` to the `types` script and fixes the 15 errors it surfaces. - 8 `no-untyped-def`: the `caplog` parameter on eight partially-annotated tests is now `pytest.LogCaptureFixture`. `test_pdf_to_image.py` gains the `pytest` import it needed for that. - 4 `union-attr`: `results["image_contents"][0]` is `ImageContent | None`, and `_convert_pdf_to_images` returns PIL images *or* base64 strings. Both are now bound to a local and narrowed - `assert image_content is not None`, and `isinstance(image, Image.Image)` matching the existing assertions further down the same file - rather than suppressed. - 3 `list-item`: `converter.run(sources=[123])` passes an int where a path is expected, which is exactly what those three tests assert the converters log about. The wrong type is the subject, so a narrow `# type: ignore[list-item]` is the honest annotation. Part of #10396.
ShousenZHANG
force-pushed
the
test/type-check-converters-image
branch
from
September 14, 2026 13:46
b25682a to
010132b
Compare
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
test/hooks/compaction/), test: enable mypy typing checks for the test/hooks root modules #12711 and test: enable mypy typing checks for test/hooks/budget #12710Proposed Changes:
Adds
test/components/converters/image/to thetypestarget. Baseline was 15 errors across all five test modules.no-untyped-def— thecaplogparameter on eight partially-annotated tests is nowpytest.LogCaptureFixture.test_pdf_to_image.pygains thepytestimport it needed for that. The fully-unannotatedtest_run_none_imagesis left alone: mypy does not check it at all, so annotating one parameter there would mean annotating all five, which is a different change.union-attr—results["image_contents"][0]isImageContent | None, and_convert_pdf_to_imagesis typed as returning PIL images or base64 strings depending onreturn_base64. Both are bound to a local and narrowed rather than suppressed:assert image_content is not None, andisinstance(image, Image.Image), which matches the assertions already intest_image_utils.pyfurther down the same file.list-item—converter.run(sources=[123])passes an int wherestr | Path | ByteStreamis expected, which is exactly what those three tests assert the converters log about. The wrong type is the subject, so a narrow# type: ignore[list-item]is the honest annotation; the inline comment says why.One suppression category, three sites, all of them tests whose subject is the type error itself. The optional-access and union-return cases were fixed structurally.
How did you test it?
mypyontest/components/converters/image/-> 15 errors.pytest test/components/converters/image/-> 59 passed.hatch run ruff check/ruff format --check-> clean.This leaves
test/components/converters/itself (12 modules, 70 errors) as the larger remaining gap in this subtree; it is not touched here.No release note: test-only, which AGENTS.md excludes from the release-note requirement.
This PR was written with AI assistance.