[Misc] Update typechecking in example_online/text_to_image#1181
[Misc] Update typechecking in example_online/text_to_image#1181Lucaskabela wants to merge 2 commits intovllm-project:mainfrom
Conversation
2c738c8 to
9572c89
Compare
Signed-off-by: Lucas Kabela <lucaskabela@meta.com>
9572c89 to
d8d4149
Compare
|
cc @Gaohan123 for review as well |
There was a problem hiding this comment.
Pull request overview
This PR updates type annotations in the examples/online_serving/text_to_image directory to ensure mypy type checking passes when run locally. The changes address mypy configuration issues and add missing type annotations to functions and variables.
Changes:
- Fixed mypy Python version configuration from invalid "3.12, 3.13" to valid "3.12"
- Added type annotations to function signatures and local variables in example scripts
- Added necessary typing imports to support type annotations
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pyproject.toml | Corrected python_version in mypy configuration from "3.12, 3.13" to "3.12" |
| examples/online_serving/text_to_image/openai_chat_client.py | Added type annotations for variables and main() function, imported typing.Any |
| examples/online_serving/text_to_image/gradio_demo.py | Added type annotations for extra_body dict, return types for create_demo() and main(), and modified Gradio Blocks instantiation pattern |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| demo = gr.Blocks(title="Qwen-Image Demo") | ||
| with demo: |
There was a problem hiding this comment.
The pattern of separating the Gradio Blocks instantiation from the context manager is inconsistent with other similar files in the codebase. For example, examples/offline_inference/text_to_image/gradio_demo.py uses with gr.Blocks(...) as demo: and also has a return type annotation of -> gr.Blocks. Consider using the more conventional pattern with gr.Blocks(title="Qwen-Image Demo") as demo: which would be consistent with the rest of the codebase and should also pass mypy type checking.
There was a problem hiding this comment.
If we return that, demo would not be in scope for the return statement at the end of the function though right?
Purpose
Updates typechecking to pass with mypy when ran locally for this
example_online/text_to_imagedirectoryTest Plan
Test Result
Before
After
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.BEFORE SUBMITTING, PLEASE READ https://github.com/vllm-project/vllm-omni/blob/main/CONTRIBUTING.md (anything written below this line will be removed by GitHub Actions)