[Refactor] Refactor import utils (#20269)

Signed-off-by: yewentao256 <zhyanwentao@126.com>
This commit is contained in:
Wentao Ye
2025-07-01 21:05:42 -04:00
committed by GitHub
parent 9290de5667
commit e81fbefe8a
4 changed files with 10 additions and 11 deletions

View File

@@ -76,7 +76,7 @@ line-length = 80
"vllm/spec_decode/**/*.py" = ["UP006", "UP035"]
"vllm/worker/**/*.py" = ["UP006", "UP035"]
# Python 3.8 typing - skip utils for ROCm
"vllm/utils.py" = ["UP006", "UP035"]
"vllm/utils/__init__.py" = ["UP006", "UP035"]
[tool.ruff.lint]
select = [

View File

@@ -25,7 +25,7 @@ infiles += [
infiles += [
"vllm/model_executor/layers/sampler.py",
"vllm/sampling_params.py",
"vllm/utils.py",
"vllm/utils/__init__.py",
]
setup(ext_modules=cythonize(infiles,

View File

@@ -26,7 +26,6 @@ except ImportError:
# add to this list if absolutely necessary and after careful security review.
ALLOWED_FILES = set([
# pickle
'vllm/utils.py',
'vllm/v1/serial_utils.py',
'vllm/v1/executor/multiproc_executor.py',
'vllm/multimodal/hasher.py',
@@ -54,7 +53,7 @@ ALLOWED_FILES = set([
'vllm/entrypoints/llm.py',
'tests/utils.py',
# pickle and cloudpickle
'vllm/utils.py',
'vllm/utils/__init__.py',
'vllm/v1/serial_utils.py',
'vllm/v1/executor/multiproc_executor.py',
'vllm/transformers_utils/config.py',

View File

@@ -39,14 +39,14 @@ from argparse import (Action, ArgumentDefaultsHelpFormatter, ArgumentParser,
from asyncio import FIRST_COMPLETED, AbstractEventLoop, Task
from collections import UserDict, defaultdict
from collections.abc import (AsyncGenerator, Awaitable, Collection, Generator,
Hashable, Iterable, Iterator, KeysView, Mapping)
Hashable, Iterable, Iterator, KeysView, Mapping,
Sequence)
from concurrent.futures.process import ProcessPoolExecutor
from dataclasses import dataclass, field
from functools import cache, lru_cache, partial, wraps
from types import MappingProxyType
from typing import (TYPE_CHECKING, Any, Callable, Generic, Literal, NamedTuple,
Optional, Sequence, Tuple, Type, TypeVar, Union, cast,
overload)
Optional, TypeVar, Union, cast, overload)
from urllib.parse import urlparse
from uuid import uuid4
@@ -1921,9 +1921,9 @@ class LazyDict(Mapping[str, T], Generic[T]):
return len(self._factory)
class ClassRegistry(UserDict[Type[T], _V]):
class ClassRegistry(UserDict[type[T], _V]):
def __getitem__(self, key: Type[T]) -> _V:
def __getitem__(self, key: type[T]) -> _V:
for cls in key.mro():
if cls in self.data:
return self.data[cls]
@@ -2234,7 +2234,7 @@ def direct_register_custom_op(
fake_impl: Optional[Callable] = None,
target_lib: Optional[Library] = None,
dispatch_key: str = "CUDA",
tags: Tuple[torch.Tag, ...] = (),
tags: tuple[torch.Tag, ...] = (),
):
"""
`torch.library.custom_op` can have significant overhead because it
@@ -2489,7 +2489,7 @@ def get_exception_traceback():
return err_str
def split_zmq_path(path: str) -> Tuple[str, str, str]:
def split_zmq_path(path: str) -> tuple[str, str, str]:
"""Split a zmq path into its parts."""
parsed = urlparse(path)
if not parsed.scheme: