diff --git a/src/llama_stack/providers/inline/post_training/huggingface/recipes/finetune_single_device.py b/src/llama_stack/providers/inline/post_training/huggingface/recipes/finetune_single_device.py index 4506a2351..39b83a3fd 100644 --- a/src/llama_stack/providers/inline/post_training/huggingface/recipes/finetune_single_device.py +++ b/src/llama_stack/providers/inline/post_training/huggingface/recipes/finetune_single_device.py @@ -358,6 +358,10 @@ class HFFinetuningSingleDevice: if peft_config: logger.info("Merging LoRA weights with base model") # TRL's merge_and_unload returns a HuggingFace model + # Both cast() and type: ignore are needed here: + # - cast() tells mypy the return type is HFAutoModel for downstream code + # - type: ignore suppresses errors on the merge_and_unload() call itself, + # which mypy can't type-check due to TRL library's incomplete type stubs model_obj = cast(HFAutoModel, trainer.model.merge_and_unload()) # type: ignore[union-attr,operator] else: # trainer.model is the trained HuggingFace model diff --git a/src/llama_stack/testing/api_recorder.py b/src/llama_stack/testing/api_recorder.py index dfa541872..eb43019c9 100644 --- a/src/llama_stack/testing/api_recorder.py +++ b/src/llama_stack/testing/api_recorder.py @@ -599,6 +599,10 @@ def _combine_model_list_responses(endpoint: str, records: list[dict[str, Any]]) if endpoint == "/api/tags": from ollama import ListResponse + # Both cast(Any, ...) and type: ignore are needed here: + # - cast(Any, ...) attempts to bypass type checking on the argument + # - type: ignore is still needed because mypy checks the call site independently + # and reports arg-type mismatch even after casting body = ListResponse(models=cast(Any, ordered)) # type: ignore[arg-type] return {"request": canonical_req, "response": {"body": body, "is_streaming": False}}