Skip to content

Commit b5232c7

Browse files
skyloevilpaulpak58
authored andcommitted
[refactor] improve ConstantList exception specificity (vllm-project#22156)
Signed-off-by: zitian.zhao <zitian.zhao@tencentmusic.com> Signed-off-by: Paul Pak <paulpak58@gmail.com>
1 parent 07e695e commit b5232c7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

vllm/v1/utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@ def __init__(self, x: list[T]) -> None:
3434
self._x = x
3535

3636
def append(self, item):
37-
raise Exception("Cannot append to a constant list")
37+
raise TypeError("Cannot append to a constant list")
3838

3939
def extend(self, item):
40-
raise Exception("Cannot extend a constant list")
40+
raise TypeError("Cannot extend a constant list")
4141

4242
def insert(self, item):
43-
raise Exception("Cannot insert into a constant list")
43+
raise TypeError("Cannot insert into a constant list")
4444

4545
def pop(self, item):
46-
raise Exception("Cannot pop from a constant list")
46+
raise TypeError("Cannot pop from a constant list")
4747

4848
def remove(self, item):
49-
raise Exception("Cannot remove from a constant list")
49+
raise TypeError("Cannot remove from a constant list")
5050

5151
def clear(self):
52-
raise Exception("Cannot clear a constant list")
52+
raise TypeError("Cannot clear a constant list")
5353

5454
def index(self,
5555
item: T,
@@ -78,10 +78,10 @@ def __setitem__(self, s: slice, value: T, /):
7878
...
7979

8080
def __setitem__(self, item: Union[int, slice], value: Union[T, list[T]]):
81-
raise Exception("Cannot set item in a constant list")
81+
raise TypeError("Cannot set item in a constant list")
8282

8383
def __delitem__(self, item):
84-
raise Exception("Cannot delete item from a constant list")
84+
raise TypeError("Cannot delete item from a constant list")
8585

8686
def __iter__(self):
8787
return iter(self._x)

0 commit comments

Comments
 (0)