chore: fix mypy types (1st pass)
What does this merge request do and why?
Follow up from this MR: !729 (merged)
I attempted to fix some of the types with minimal logic changes.
Brought it down from 259 errors to 190ish. It might be best if we do this in iterations. Some of the errors pertain to class inheritance typing conflicts. For instance base.py
might need a return type change so that these signature conflicts can be resolved:
ai_gateway/models/vertex_text.py:198: error: Signature of "generate" incompatible with supertype "TextGenBaseModel" [override]
ai_gateway/models/vertex_text.py:198: note: Superclass:
ai_gateway/models/vertex_text.py:198: note: def generate(self, prefix: str, suffix: str, stream: bool = ..., temperature: float = ..., max_output_tokens: int = ..., top_p: float = ..., top_k: int = ...) -> Coroutine[Any, Any, TextGenModelOutput | AsyncIterator[TextGenModelChunk]]
ai_gateway/models/vertex_text.py:198: note: Subclass:
ai_gateway/models/vertex_text.py:198: note: def generate(self, prompt: str, suffix: str, stream: bool = ..., temperature: float = ..., max_output_tokens: int = ..., top_p: float = ..., top_k: int = ..., stop_sequences: Sequence[str] | None = ...) -> Coroutine[Any, Any, TextGenModelOutput | None]
However, any changes to base.py
might also cause conflicts with anthropic.py
and mock.py
(the classes that inherit the base.py
implementation).
Also, maybe we should wait to solve the typing issues in app.py
as a majority of them may be fixed in this MR !728 (merged).
Contributes to #436
How to set up and validate locally
Check this branch out and run make check-mypy TODO=true
.
Merge request checklist
-
Tests added for new functionality. If not, please raise an issue to follow up. -
Documentation added/updated, if needed.
Edited by Tan Le