test: type-check test/utils and add it to mypy config#11728
Open
mustafakhokhar wants to merge 3 commits into
Open
test: type-check test/utils and add it to mypy config#11728mustafakhokhar wants to merge 3 commits into
mustafakhokhar wants to merge 3 commits into
Conversation
Enable mypy type checking for the test/utils directory (part of deepset-ai#10396) as a first piece-meal step toward typing the whole test suite. Fix the errors mypy surfaced across 11 files using real annotations where possible (annotating expected values, adding return types, narrowing float | None with asserts, annotating mock parameters). Where a test intentionally passes invalid input (inside pytest.raises) or monkeypatches a method, a scoped and commented type: ignore is used. No test behaviour is changed. Add test/utils/ to the test:types mypy paths in pyproject.toml.
|
@mustafakhokhar is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
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/utils)Proposed Changes:
A first incremental step toward typing the whole test suite, as suggested in #10396 ("do it in a piece-meal approach where we only turn on type checking in a small part of tests and grow from there").
test/utils/to thetest:typesmypy paths inpyproject.toml.test/utilspassmypyby fixing the errors it surfaced across 11 files, preferring real type annotations (annotatingexpectedvalues, adding-> None/ parameter types, narrowingfloat | Nonewithassert ... is not None, annotating mock parameters).pytest.raises) or monkeypatches a method, a scoped, commented# type: ignore[<code>]is used (no bare ignores).How did you test it?
hatch run test:types→ clean (now also type-checkstest/utils).hatch run test:unit test/utils/→ passes (see reviewer note about one unrelated pre-existing failure).hatch run fmtand the pre-commit hooks are clean.Notes for the reviewer
haystack/source changes), so no release note is included.test/utils/test_type_serialization.py::test_output_type_serialization_typing_generic_with_nonetypefails only on Python 3.14 (Union[str, int, None]now reprs asstr | int | None). This is unrelated to this PR, reproduces onmain, and that assertion is untouched here.# type: ignorecomments are scoped to specific error codes with a short justification — happy to adjust any.Checklist
test:).ignore-for-release-notes).Implemented with the help of an AI assistant; I have reviewed all changes and run the relevant tests and quality checks.