Skip to content

[Misc] Update typechecking in example_online/text_to_image#1181

Open
Lucaskabela wants to merge 2 commits intovllm-project:mainfrom
Lucaskabela:lucaskabela/updated_mypy_for_examples
Open

[Misc] Update typechecking in example_online/text_to_image#1181
Lucaskabela wants to merge 2 commits intovllm-project:mainfrom
Lucaskabela:lucaskabela/updated_mypy_for_examples

Conversation

@Lucaskabela
Copy link

@Lucaskabela Lucaskabela commented Feb 3, 2026

Purpose

Updates typechecking to pass with mypy when ran locally for this example_online/text_to_image directory

Test Plan

mypy examples/online_serving/text_to_image/

Test Result

Before

pyproject.toml: [mypy]: python_version: Invalid python version '3.12, 3.13' (expected format: 'x.y')
examples/online_serving/text_to_image/openai_chat_client.py:90: error: Function is missing a return type annotation  [no-untyped-def]
examples/online_serving/text_to_image/openai_chat_client.py:90: note: Use "-> None" if function does not return a value
examples/online_serving/text_to_image/gradio_demo.py:42: error: Incompatible types in assignment (expression has type "str", target has type "float")  [assignment]
examples/online_serving/text_to_image/gradio_demo.py:74: error: Function is missing a return type annotation  [no-untyped-def]
examples/online_serving/text_to_image/gradio_demo.py:172: error: Function is missing a return type annotation  [no-untyped-def]
examples/online_serving/text_to_image/gradio_demo.py:172: note: Use "-> None" if function does not return a value
Found 4 errors in 2 files (checked 2 source files)

After

Success: no issues found in 2 source files

Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft.

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)

@Lucaskabela Lucaskabela force-pushed the lucaskabela/updated_mypy_for_examples branch from 2c738c8 to 9572c89 Compare February 3, 2026 23:12
Signed-off-by: Lucas Kabela <lucaskabela@meta.com>
@Lucaskabela Lucaskabela force-pushed the lucaskabela/updated_mypy_for_examples branch from 9572c89 to d8d4149 Compare February 3, 2026 23:28
@Lucaskabela
Copy link
Author

cc @Gaohan123 for review as well

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +77 to +78
demo = gr.Blocks(title="Qwen-Image Demo")
with demo:
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we return that, demo would not be in scope for the return statement at the end of the function though right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant