Skip to content

test: enable mypy typing checks for test/components/converters/image - #12750

Merged
anakin87 merged 1 commit into
deepset-ai:mainfrom
ShousenZHANG:test/type-check-converters-image
Sep 14, 2026
Merged

anakin87 merged 1 commit into
deepset-ai:mainfrom
ShousenZHANG:test/type-check-converters-image

Conversation

@ShousenZHANG

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

Adds test/components/converters/image/ to the types target. Baseline was 15 errors across all five test modules.

  • 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. The fully-unannotated test_run_none_images is left alone: mypy does not check it at all, so annotating one parameter there would mean annotating all five, which is a different change.
  • 4 union-attr — results["image_contents"][0] is ImageContent | None, and _convert_pdf_to_images is typed as returning PIL images or base64 strings depending on return_base64. Both are bound to a local and narrowed rather than suppressed: assert image_content is not None, and isinstance(image, Image.Image), which matches the assertions already in test_image_utils.py further down the same file.
  • 3 list-item — converter.run(sources=[123]) passes an int where str | Path | ByteStream 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; 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?

  • Before: mypy on test/components/converters/image/ -> 15 errors.
  • After: zero 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.

Copilot AI lite review requested due to automatic review settings September 14, 2026 12:02
@ShousenZHANG
ShousenZHANG requested a review from a team as a code owner September 14, 2026 12:02
@ShousenZHANG
ShousenZHANG requested review from anakin87 and removed request for a team September 14, 2026 12:02
@vercel

vercel Bot commented Sep 14, 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

Copy link
Copy Markdown
Contributor

Coverage report

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

@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.

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
ShousenZHANG force-pushed the test/type-check-converters-image branch from b25682a to 010132b Compare September 14, 2026 13:46

@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 14, 2026 13:49
@anakin87
anakin87 merged commit 375211e into deepset-ai:main Sep 14, 2026
21 of 22 checks passed
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