Repository navigation
test: enable mypy typing checks for test/hooks/budget - #12710
Merged
Merged
Conversation
Adds `test/hooks/budget/` to the `types` target and fixes the three errors it surfaces in `test_hooks.py`: - `KeepIterating`, the inline stub passed as an `on_exit` hook, was missing the `to_dict` / `from_dict` members the `Hook` protocol requires. Implemented via `default_to_dict` / `default_from_dict`, matching the `LifecycleHook` stubs in `test/components/agents/test_agent_hooks.py`. - the two `agent.chat_generator.run = MagicMock(...)` lines carry a narrow `# type: ignore[method-assign]`; replacing a bound method on a mock generator is the intended pattern here, not something to restructure. `mypy test/hooks/budget/` is clean, and `pytest test/hooks/budget/` is 10 passed.
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
This was referenced Sep 11, 2026
This was referenced Sep 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.
Related Issues
Proposed Changes:
Adds
test/hooks/budget/to thetypestarget inpyproject.tomland fixes the three errors it surfaces.test/hooks/is only partially covered today — the argument list carriestest/hooks/human_in_the_loopand nothing else, sobudget/,compaction/,tool_result_offloading/and the three roottest_*.pyfiles are unchecked. This takes the smallest of those.Baseline: 3 errors in
test/hooks/budget/test_hooks.py.list-itemat L106.KeepIterating, an inline stub passed as anon_exithook, lacks theto_dict/from_dictmembers theHookprotocol requires. Implemented withdefault_to_dict/default_from_dict— the same shape as theLifecycleHookstubs test: type-check agent hook and confirmation tests #12681 added intest/components/agents/test_agent_hooks.py. Fixed structurally, no suppression.method-assignat L91 and L109, bothagent.chat_generator.run = MagicMock(...). Replacing a bound method on a mock chat generator is the intended pattern in these tests, so each carries a narrow# type: ignore[method-assign]rather than being restructured.Per AGENTS.md I kept
type: ignoreto the cases where it is actually necessary.How did you test it?
mypy test/hooks/budget/-> 3 errors in 1 file.typestarget.pytest test/hooks/budget/-> 10 passed.hatch run fmt-check-> clean, 6804 files.One note on my environment: the full
typestarget reports 14 errors undertest/components/generators/, but they reproduce identically on cleanmain— my localopenaipackage is older than CI's, so those are environment noise rather than anything this PR touches.No release note: test-only, which AGENTS.md excludes from the release-note requirement.
This PR was written with AI assistance.