Repository navigation
test: enable mypy typing checks for the test/hooks root modules - #12711
Merged
julian-risch merged 2 commits intoSep 14, 2026
Merged
Conversation
Adds `test/hooks/test_from_function.py`, `test_invocation.py` and `test_utils.py` to the `types` target. Baseline was 56 errors, and almost all of them came from one cause. - 44 `list-item` / `arg-type` errors traced to six inline stub hooks — `RecordingHook`, `ThreadRecordingHook`, `AsyncRecordingHook`, `LifecycleSpy`, `WarmOnlyHook`, `PlainHook` — missing the `to_dict` / `from_dict` members the `Hook` protocol requires. Implemented with `default_to_dict` / `default_from_dict`, matching the `LifecycleHook` stubs in `test/components/agents/test_agent_hooks.py`. - The remaining `arg-type` errors were hook dictionaries inferred as `dict[str, ...]` where the callee wants `HookPoint` keys; they now carry an explicit `dict[HookPoint, list[Hook]]` annotation. - `test_utils.py` read `.function` off a `Hook`, which only `FunctionHook` has. Narrowed with `isinstance` instead of suppressing. - Five suppressions remain, all in `TestFunctionHookConstruction`, where the test passes a deliberately wrong callable to assert `FunctionHook` rejects it — the type error is the thing under test. `mypy` on the three files is clean, `pytest test/hooks/` is 325 passed / 1 skipped, and `fmt-check` is clean across 6804 files.
ShousenZHANG
requested review from
julian-risch
and removed request for
a team
September 11, 2026 12:19
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
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
…-root Keep both the test/hooks/budget/ target from #12710 and the three test/hooks root modules added here. Co-Authored-By: Claude Fable 5.1 <[email protected]>
julian-risch
approved these changes
Sep 14, 2026
julian-risch
left a comment
Member
There was a problem hiding this comment.
Looks good to me! Thank you @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
test/hooks/budget/)Proposed Changes:
Adds
test/hooks/test_from_function.py,test_invocation.pyandtest_utils.pyto thetypestarget. Baseline was 56 errors; almost all of them had one cause.list-item/arg-typetraced to six inline stub hooks —RecordingHook,ThreadRecordingHook,AsyncRecordingHook,LifecycleSpy,WarmOnlyHook,PlainHook— missing theto_dict/from_dictmembers theHookprotocol requires. Implemented withdefault_to_dict/default_from_dict, matching theLifecycleHookstubs intest/components/agents/test_agent_hooks.py. Fixed structurally, no suppressions.arg-type: hook dictionaries inferred asdict[str, ...]where_run_hooks/_run_hooks_async/_serialize_hooks_dictionarywantHookPointkeys. They now carry an explicitdict[HookPoint, list[Hook]]annotation.attr-defined:test_utils.pyread.functionoff aHook, which onlyFunctionHookdeclares. Narrowed withisinstancerather than suppressed, which also makes the assertion say what it means.TestFunctionHookConstruction. Those tests pass a deliberately wrong callable — a coroutine into the sync slot, a zero-parameter function, an unannotated parameter — to assertFunctionHookraises. The type error is the thing under test, so a narrow# type: ignore[arg-type]/[no-untyped-def]is the honest annotation.Per AGENTS.md, suppressions are limited to the cases where they are actually necessary; the largest group was fixed structurally instead.
How did you test it?
mypyon the three files -> 56 errors.test/hooks/within the fulltypestarget.pytest test/hooks/-> 325 passed, 1 skipped.hatch run fmt-check-> clean, 6804 files.compaction/andtool_result_offloading/are still outside the target — they are the larger remaining gaps and are not touched here.No release note: test-only, which AGENTS.md excludes from the release-note requirement.
This PR was written with AI assistance.