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 09:51:31 -07:00
committed by GitHub
parent 9bb38130cb
commit 8fcaaf6a16
944 changed files with 9490 additions and 10121 deletions
+3 -4
View File
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import random
from typing import Optional, Union
import msgspec
import msgspec.msgpack
@@ -78,8 +77,8 @@ class MockSubscriber:
def __init__(
self,
pub_endpoints: Union[str, list[str]],
replay_endpoints: Optional[Union[str, list[str]]] = None,
pub_endpoints: str | list[str],
replay_endpoints: str | list[str] | None = None,
topic: str = "",
decode_type=SampleBatch,
):
@@ -111,7 +110,7 @@ class MockSubscriber:
self.last_seq = -1
self.decoder = msgspec.msgpack.Decoder(type=decode_type)
def receive_one(self, timeout=1000) -> Union[tuple[int, SampleBatch], None]:
def receive_one(self, timeout=1000) -> tuple[int, SampleBatch] | None:
"""Receive a single message with timeout"""
if not self.sub.poll(timeout):
return None
+2 -3
View File
@@ -5,9 +5,8 @@
Run `pytest tests/distributed/test_comm_ops.py`.
"""
from __future__ import annotations
from typing import Any, Callable
from collections.abc import Callable
from typing import Any
import pytest
import ray
+3 -3
View File
@@ -11,7 +11,7 @@ WARNING: This test runs in both single-node (4 GPUs) and multi-node
import json
import os
from dataclasses import dataclass
from typing import Literal, NamedTuple, Optional
from typing import Literal, NamedTuple
import pytest
@@ -36,7 +36,7 @@ class ParallelSetup(NamedTuple):
class CPTestOptions(NamedTuple):
multi_node_only: bool
load_format: Optional[str] = None
load_format: str | None = None
@dataclass
@@ -54,7 +54,7 @@ class CPTestSettings:
dcp_base: int = 1,
multi_node_only: bool = False,
runner: RunnerOption = "auto",
load_format: Optional[str] = None,
load_format: str | None = None,
):
parallel_setups = []
for eager_mode_val in [False]:
+10 -10
View File
@@ -2,7 +2,7 @@
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from dataclasses import dataclass
from typing import Literal, NamedTuple, Optional
from typing import Literal, NamedTuple
import pytest
@@ -22,9 +22,9 @@ class ParallelSetup(NamedTuple):
class EPTestOptions(NamedTuple):
trust_remote_code: bool
tokenizer_mode: Optional[str]
load_format: Optional[str] = None
hf_overrides: Optional[str] = None
tokenizer_mode: str | None
load_format: str | None = None
hf_overrides: str | None = None
@dataclass
@@ -40,9 +40,9 @@ class EPTestSettings:
tp_base: int = 2,
runner: RunnerOption = "auto",
trust_remote_code: bool = False,
tokenizer_mode: Optional[str] = None,
load_format: Optional[str] = None,
hf_overrides: Optional[str] = None,
tokenizer_mode: str | None = None,
load_format: str | None = None,
hf_overrides: str | None = None,
):
return EPTestSettings(
parallel_setups=[
@@ -72,9 +72,9 @@ class EPTestSettings:
tp_base: int = 2,
runner: RunnerOption = "auto",
trust_remote_code: bool = False,
tokenizer_mode: Optional[str] = None,
load_format: Optional[str] = None,
hf_overrides: Optional[str] = None,
tokenizer_mode: str | None = None,
load_format: str | None = None,
hf_overrides: str | None = None,
):
return EPTestSettings(
parallel_setups=[
+4 -4
View File
@@ -11,7 +11,7 @@ WARNING: This test runs in both single-node (4 GPUs) and multi-node
import json
import os
from dataclasses import dataclass
from typing import Literal, NamedTuple, Optional
from typing import Literal, NamedTuple
import pytest
@@ -35,7 +35,7 @@ class ParallelSetup(NamedTuple):
class PPTestOptions(NamedTuple):
multi_node_only: bool
load_format: Optional[str] = None
load_format: str | None = None
@dataclass
@@ -52,7 +52,7 @@ class PPTestSettings:
pp_base: int = 2,
multi_node_only: bool = False,
runner: RunnerOption = "auto",
load_format: Optional[str] = None,
load_format: str | None = None,
):
return PPTestSettings(
parallel_setups=[
@@ -76,7 +76,7 @@ class PPTestSettings:
pp_base: int = 2,
runner: RunnerOption = "auto",
multi_node_only: bool = False,
load_format: Optional[str] = None,
load_format: str | None = None,
):
return PPTestSettings(
parallel_setups=[
+1 -7
View File
@@ -1,16 +1,10 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from typing_extensions import LiteralString
from ..utils import compare_two_settings, create_new_process_for_each_test
if TYPE_CHECKING:
from typing_extensions import LiteralString
@pytest.mark.parametrize(
"PP_SIZE, MODEL_NAME",
+5 -5
View File
@@ -11,7 +11,7 @@ WARNING: This test runs in both single-node (4 GPUs) and multi-node
import json
import os
from dataclasses import dataclass
from typing import Literal, NamedTuple, Optional
from typing import Literal, NamedTuple
import pytest
@@ -36,7 +36,7 @@ class ParallelSetup(NamedTuple):
class SPTestOptions(NamedTuple):
multi_node_only: bool
load_format: Optional[str] = None
load_format: str | None = None
@dataclass
@@ -53,7 +53,7 @@ class SPTestSettings:
pp_base: int = 1,
multi_node_only: bool = False,
runner: RunnerOption = "auto",
load_format: Optional[str] = None,
load_format: str | None = None,
):
parallel_setups = []
for eager_mode_val in [False, True]:
@@ -84,7 +84,7 @@ class SPTestSettings:
pp_base: int = 1,
runner: RunnerOption = "auto",
multi_node_only: bool = False,
load_format: Optional[str] = None,
load_format: str | None = None,
):
parallel_setups = []
for eager_mode_val in [False, True]:
@@ -115,7 +115,7 @@ class SPTestSettings:
pp_base: int = 1,
runner: RunnerOption = "auto",
multi_node_only: bool = False,
load_format: Optional[str] = None,
load_format: str | None = None,
):
parallel_setups = []
for fusion_val in [False, True]: