Update Optional[x] -> x | None and Union[x, y] to x | y (#26633)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Harry Mellor
2025-10-12 17:51:31 +01:00
committed by GitHub
parent 9bb38130cb
commit 8fcaaf6a16
944 changed files with 9490 additions and 10121 deletions

View File

@@ -3,7 +3,7 @@
from collections.abc import Iterator
from enum import Enum
from typing import NamedTuple, Optional
from typing import NamedTuple
import regex as re
import torch
@@ -23,7 +23,7 @@ class BatchLogprobsComposition(Enum):
SAMPLE_PROMPT = 3
BatchLogprobsSpecType = list[tuple[Optional[int], Optional[int]]]
BatchLogprobsSpecType = list[tuple[int | None, int | None]]
def get_test_batch(
@@ -222,8 +222,8 @@ def create_allowed_token_ids(
vocab_size: int,
num_allowed_token_ids: int,
device: torch.device,
) -> Optional[torch.Tensor]:
mask: Optional[torch.Tensor] = None
) -> torch.Tensor | None:
mask: torch.Tensor | None = None
for i in range(batch_size):
if i % 2 == 1:
continue