Skip to content

chore(mypy): fix type hints for inline provider files#5399

Open
Elbehery wants to merge 2 commits intollamastack:mainfrom
Elbehery:20260401_add_type_hints_cli_module
Open

chore(mypy): fix type hints for inline provider files#5399
Elbehery wants to merge 2 commits intollamastack:mainfrom
Elbehery:20260401_add_type_hints_cli_module

Conversation

@Elbehery
Copy link
Copy Markdown
Contributor

@Elbehery Elbehery commented Apr 1, 2026

What does this PR do?

Fix mypy strict type checking errors in inline provider files:

  1. Fixed SentenceTransformerEmbeddingMixin.model_store type to match InferenceProvider protocol (ModelStore | None instead of ModelStore)

  2. Fixed eval.py type errors:

    • Added type annotations for jobs and benchmarks dicts
    • Fixed variable shadowing in benchmark iteration
    • Added proper type annotations for sampling_params (dict[str, Any])
    • Fixed message type handling with proper union types
    • Separated completion and chat_completion variable scopes
    • Added assertions for non-streaming responses
    • Added assertion for non-None content in chat responses

cc @leseb

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 1, 2026
@Elbehery Elbehery force-pushed the 20260401_add_type_hints_cli_module branch 2 times, most recently from 7a3ad27 to 1281090 Compare April 1, 2026 13:35
@Elbehery Elbehery force-pushed the 20260401_add_type_hints_cli_module branch 3 times, most recently from 14e8aaf to 8827ae4 Compare April 1, 2026 20:29
Fix mypy strict type checking errors in 27 inline provider files:

1. Fixed SentenceTransformerEmbeddingMixin.model_store type to match
   InferenceProvider protocol (ModelStore | None instead of ModelStore)

2. Fixed eval.py type errors:
   - Added type annotations for jobs and benchmarks dicts
   - Fixed variable shadowing in benchmark iteration
   - Added proper type annotations for sampling_params (dict[str, Any])
   - Fixed message type handling with proper union types
   - Separated completion and chat_completion variable scopes
   - Added assertions for non-streaming responses
   - Added assertion for non-None content in chat responses

Signed-off-by: Mustafa Elbehery <melbeher@redhat.com>
@Elbehery Elbehery force-pushed the 20260401_add_type_hints_cli_module branch from 05f6441 to 5399717 Compare April 1, 2026 21:00
…easoning

Fix mypy override errors in transformers and sentence_transformers inference
providers by adding the correct return type annotation for the
openai_chat_completions_with_reasoning method.

Changes:
- Import OpenAIChatCompletionWithReasoning and
  OpenAIChatCompletionChunkWithReasoning types
- Update method signature from `-> None` to
  `-> OpenAIChatCompletionWithReasoning | AsyncIterator[OpenAIChatCompletionChunkWithReasoning]`
  to match the InferenceProvider protocol

The methods still raise NotImplementedError as these providers don't support
reasoning, but now have the correct type annotation for protocol compliance.

Signed-off-by: Mustafa Elbehery <melbeher@redhat.com>
@Elbehery Elbehery force-pushed the 20260401_add_type_hints_cli_module branch from 5399717 to 03a5f2a Compare April 1, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant