chore: make mypy errors in ai_gateway/api itterable to solve
What does this merge request do and why?
We are pivoting this MR and instead breaking up the effort to combat our technical debt in the ai_gateway/api folder because if we do not the reviewer will have to consider over 83 fixes in one MR which is excessive.
Some work has already been done to address the following errors and that work will remain in this MR.
ai_gateway/api/middleware/feature_flag.py:12: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
ai_gateway/api/middleware/feature_flag.py:12: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
ai_gateway/api/monitoring.py:147: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
ai_gateway/api/monitoring.py:147: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
ai_gateway/api/v3/code/completions.py:267: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
ai_gateway/api/v3/code/completions.py:267: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
ai_gateway/api/monitoring.py:94: error: Argument "role" to "Message" has incompatible type "str"; expected "Role" [arg-type]
ai_gateway/api/monitoring.py:95: error: Argument "role" to "Message" has incompatible type "str"; expected "Role" [arg-type]
ai_gateway/api/monitoring.py:146: error: "Configuration" expects no type arguments, but 1 given [type-arg]
Next Steps:
After this MR we will address errors in each sub folder/file depending on the size. Here is a break down of the outstanding errors
{
"ai_gateway/api/middleware/model_config.py": 2,
"ai_gateway/api/middleware/base.py": 1,
"ai_gateway/api/snowplow_context.py": 2,
"ai_gateway/api/v3/code/completions.py": 40,
"ai_gateway/api/v2/code/completions.py": 29,
"ai_gateway/api/v2/chat/agent.py": 4,
"ai_gateway/api/v1/x_ray/libraries.py": 1,
"ai_gateway/api/v1/prompts/invoke.py": 1,
"ai_gateway/api/v1/chat/agent.py": 3,
"ai_gateway/api/server.py": 3
}
Merge request checklist
-
Tests added for new functionality. If not, please raise an issue to follow up. -
Documentation added/updated, if needed.
Closes #842 (closed)
Edited by Stephan Rayner