mirror of
https://github.com/codeflash-ai/codeflash-internal.git
synced 2026-05-04 18:25:18 +00:00
fix: add cast to satisfy ty type checker for list covariance
The ty type checker correctly flags that list[str] is not a subtype of list[str | None] due to list invariance. Added explicit cast. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
16e043883a
commit
bf4e38c301
1 changed files with 2 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from typing import TYPE_CHECKING, Any, cast
|
||||
|
||||
import sentry_sdk
|
||||
from asgiref.sync import sync_to_async
|
||||
|
|
@ -20,7 +20,7 @@ features_api = NinjaAPI(urls_namespace="log_features")
|
|||
def _positional_list(items: list[str] | None, index: int | None) -> list[str | None] | None:
|
||||
"""Place a single item at the correct index, padding with None."""
|
||||
if not items or index is None or len(items) != 1:
|
||||
return items
|
||||
return cast("list[str | None] | None", items)
|
||||
result: list[str | None] = [None] * (index + 1)
|
||||
result[index] = items[0]
|
||||
return result
|
||||
|
|
|
|||
Loading…
Reference in a new issue