Skip to content

Commit e81fbef

Browse files
authored
[Refactor] Refactor import utils (#20269)
Signed-off-by: yewentao256 <zhyanwentao@126.com>
1 parent 9290de5 commit e81fbef

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ line-length = 80
7676
"vllm/spec_decode/**/*.py" = ["UP006", "UP035"]
7777
"vllm/worker/**/*.py" = ["UP006", "UP035"]
7878
# Python 3.8 typing - skip utils for ROCm
79-
"vllm/utils.py" = ["UP006", "UP035"]
79+
"vllm/utils/__init__.py" = ["UP006", "UP035"]
8080

8181
[tool.ruff.lint]
8282
select = [

tests/build_cython.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
infiles += [
2626
"vllm/model_executor/layers/sampler.py",
2727
"vllm/sampling_params.py",
28-
"vllm/utils.py",
28+
"vllm/utils/__init__.py",
2929
]
3030

3131
setup(ext_modules=cythonize(infiles,

tools/check_pickle_imports.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
# add to this list if absolutely necessary and after careful security review.
2727
ALLOWED_FILES = set([
2828
# pickle
29-
'vllm/utils.py',
3029
'vllm/v1/serial_utils.py',
3130
'vllm/v1/executor/multiproc_executor.py',
3231
'vllm/multimodal/hasher.py',
@@ -54,7 +53,7 @@
5453
'vllm/entrypoints/llm.py',
5554
'tests/utils.py',
5655
# pickle and cloudpickle
57-
'vllm/utils.py',
56+
'vllm/utils/__init__.py',
5857
'vllm/v1/serial_utils.py',
5958
'vllm/v1/executor/multiproc_executor.py',
6059
'vllm/transformers_utils/config.py',

vllm/utils.py renamed to vllm/utils/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@
3939
from asyncio import FIRST_COMPLETED, AbstractEventLoop, Task
4040
from collections import UserDict, defaultdict
4141
from collections.abc import (AsyncGenerator, Awaitable, Collection, Generator,
42-
Hashable, Iterable, Iterator, KeysView, Mapping)
42+
Hashable, Iterable, Iterator, KeysView, Mapping,
43+
Sequence)
4344
from concurrent.futures.process import ProcessPoolExecutor
4445
from dataclasses import dataclass, field
4546
from functools import cache, lru_cache, partial, wraps
4647
from types import MappingProxyType
4748
from typing import (TYPE_CHECKING, Any, Callable, Generic, Literal, NamedTuple,
48-
Optional, Sequence, Tuple, Type, TypeVar, Union, cast,
49-
overload)
49+
Optional, TypeVar, Union, cast, overload)
5050
from urllib.parse import urlparse
5151
from uuid import uuid4
5252

@@ -1921,9 +1921,9 @@ def __len__(self):
19211921
return len(self._factory)
19221922

19231923

1924-
class ClassRegistry(UserDict[Type[T], _V]):
1924+
class ClassRegistry(UserDict[type[T], _V]):
19251925

1926-
def __getitem__(self, key: Type[T]) -> _V:
1926+
def __getitem__(self, key: type[T]) -> _V:
19271927
for cls in key.mro():
19281928
if cls in self.data:
19291929
return self.data[cls]
@@ -2234,7 +2234,7 @@ def direct_register_custom_op(
22342234
fake_impl: Optional[Callable] = None,
22352235
target_lib: Optional[Library] = None,
22362236
dispatch_key: str = "CUDA",
2237-
tags: Tuple[torch.Tag, ...] = (),
2237+
tags: tuple[torch.Tag, ...] = (),
22382238
):
22392239
"""
22402240
`torch.library.custom_op` can have significant overhead because it
@@ -2489,7 +2489,7 @@ def get_exception_traceback():
24892489
return err_str
24902490

24912491

2492-
def split_zmq_path(path: str) -> Tuple[str, str, str]:
2492+
def split_zmq_path(path: str) -> tuple[str, str, str]:
24932493
"""Split a zmq path into its parts."""
24942494
parsed = urlparse(path)
24952495
if not parsed.scheme:

0 commit comments

Comments
 (0)