checks: support pydantic-compatible input types#2450
Merged
kevinmessiaen merged 4 commits intoMay 14, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request expands the input type support for generators and interactions beyond BaseModel to include any Pydantic-compatible types, such as list, int, and dict. The changes include updating type hints in InputGenerator, refining the type inference logic in interact.py using TypeAdapter, and making LLMGeneratorOutput generic. Comprehensive tests were added to verify the inference and generation of these new supported types. Feedback was provided regarding a redundant TypeAdapter call in the LLMGenerator implementation that can be removed to simplify the code.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
kevinmessiaen
requested changes
May 14, 2026
Member
kevinmessiaen
left a comment
There was a problem hiding this comment.
Thanks for your submission, this look great. I have some minor suggestions
- Use type[Any] | None instead of Any | None for input_type parameters - Improve third overload: type[T] -> AsyncGenerator[T, TraceType] (proper generic) - Remove str special-case in _infer_input_type; let str pass through so callers can distinguish typed vs untyped - Catch specific PydanticUserError/TypeError instead of bare except in TypeAdapter guard - Remove redundant TypeAdapter(T) validation call in BaseLLMGenerator.__call__ - Update tests to match new str-passthrough behavior and add TypeAdapter failure path test Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Return type is type | None (not Any | None), and the docstring now correctly states str is returned rather than excluded. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
kevinmessiaen
approved these changes
May 14, 2026
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.
Closes #2449
Summary
_infer_input_typeto return Pydantic-compatible annotations beyondBaseModelInputGenerator.__call__andLLMGeneratorOutputtyping for non-BaseModel inputsTypeAdapterlist[str],int,dict[str, Any], andMyModel | NoneTesting
uv run -m pytest -q libs/giskard-checks/tests/core/test_input_type_inference.py libs/giskard-checks/tests/core/ test_input_generator.py libs/giskard-checks/tests/generators/test_llm_generator.pyuv run ruff check ...uv run basedpyright ...