Skip to content

Commit 6f8024f

Browse files
committed
Fix type casting for model list retrieval in CopilotClient
1 parent bbd912d commit 6f8024f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

python/copilot/client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -923,13 +923,16 @@ async def list_models(self) -> list["ModelInfo"]:
923923
if self._models_cache is not None:
924924
return list(self._models_cache) # Return a copy to prevent cache mutation
925925

926+
models: list[ModelInfo]
926927
if self._on_list_models:
927928
# Use custom handler instead of CLI RPC
928929
result = self._on_list_models()
930+
# cast needed: inspect.isawaitable isn't a type guard, so the
931+
# linter can't narrow list[ModelInfo] | Awaitable[list[ModelInfo]]
929932
if inspect.isawaitable(result):
930-
models = await result
933+
models = cast(list[ModelInfo], await result)
931934
else:
932-
models = result
935+
models = cast(list[ModelInfo], result)
933936
else:
934937
if not self._client:
935938
raise RuntimeError("Client not connected")

0 commit comments

Comments
 (0)