[Misc] Replace Optional[X] with X | None syntax (#33332)

Signed-off-by: carlory <baofa.fan@daocloud.io>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
杨朱 · Kiki
2026-01-30 01:56:59 -08:00
committed by GitHub
co-authored by Claude Opus 4.5
parent c87eac18f7
commit 1a7894dbdf
56 changed files with 129 additions and 135 deletions
+2 -2
View File
@@ -7,7 +7,7 @@ pynvml. However, it should not initialize cuda context.
import os
from collections.abc import Callable
from functools import cache, wraps
from typing import TYPE_CHECKING, Optional, TypeVar
from typing import TYPE_CHECKING, TypeVar
import torch
from typing_extensions import ParamSpec
@@ -382,7 +382,7 @@ class CudaPlatformBase(Platform):
cls,
head_size: int,
dtype: torch.dtype,
backend: Optional["AttentionBackendEnum"] = None,
backend: "AttentionBackendEnum | None" = None,
) -> "AttentionBackendEnum":
if backend is not None:
assert backend in cls.get_supported_vit_attn_backends(), (
+2 -2
View File
@@ -7,7 +7,7 @@ import platform
import random
import sys
from datetime import timedelta
from typing import TYPE_CHECKING, Any, NamedTuple, Optional
from typing import TYPE_CHECKING, Any, NamedTuple
import numpy as np
import torch
@@ -243,7 +243,7 @@ class Platform:
cls,
head_size: int,
dtype: torch.dtype,
backend: Optional["AttentionBackendEnum"] = None,
backend: "AttentionBackendEnum | None" = None,
) -> "AttentionBackendEnum":
"""
Get the vision attention backend class of a device.
+2 -2
View File
@@ -3,7 +3,7 @@
import os
from functools import cache, lru_cache, wraps
from typing import TYPE_CHECKING, Optional
from typing import TYPE_CHECKING
import torch
@@ -356,7 +356,7 @@ class RocmPlatform(Platform):
cls,
head_size: int,
dtype: torch.dtype,
backend: Optional["AttentionBackendEnum"] = None,
backend: "AttentionBackendEnum | None" = None,
) -> "AttentionBackendEnum":
if backend is not None:
assert backend in cls.get_supported_vit_attn_backends(), (
+2 -2
View File
@@ -3,7 +3,7 @@
import contextlib
import os
from typing import TYPE_CHECKING, Optional
from typing import TYPE_CHECKING
import torch
@@ -88,7 +88,7 @@ class XPUPlatform(Platform):
cls,
head_size: int,
dtype: torch.dtype,
backend: Optional["AttentionBackendEnum"] = None,
backend: "AttentionBackendEnum | None" = None,
) -> "AttentionBackendEnum":
if backend is not None:
assert backend in cls.get_supported_vit_attn_backends(), (