fix: Resolve mypy type errors and fix AppStatus bug #895
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.
'Yay, linting passes' 🫠
Rationale
This PR fixes all mypy type errors that were causing pre-commit checks to fail, plus one runtime bug discovered during the investigation.
Type Fixes
DocumentBlock.dataisbytes | IOBase, but onlybyteshas.decode(). Added proper type narrowing.BaseTool,FunctionTool, etc. in its type stubs. Addedtype: ignore[attr-defined].reasoning_effortparameter accepts'xhigh'from OpenAI agents but any-llm doesn't support it yet. Added type ignore with TODO. Upstream fix: feat: add xhigh reasoning effort level any-llm#738bind_toolsreturn type wasBaseMessagebut should beAIMessageto matchBaseChatModel.Bug Fix
AppStatus.get_or_create_exit_event()doesn't exist in any version of sse-starlette. Replaced withAppStatus.should_exit = True.