mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-10 13:44:58 +08:00
[refactor] improve ConstantList exception specificity (#22156)
Signed-off-by: zitian.zhao <zitian.zhao@tencentmusic.com>
This commit is contained in:
parent
aa7012eb6d
commit
49bcd893e7
@ -34,22 +34,22 @@ class ConstantList(Generic[T], Sequence):
|
|||||||
self._x = x
|
self._x = x
|
||||||
|
|
||||||
def append(self, item):
|
def append(self, item):
|
||||||
raise Exception("Cannot append to a constant list")
|
raise TypeError("Cannot append to a constant list")
|
||||||
|
|
||||||
def extend(self, item):
|
def extend(self, item):
|
||||||
raise Exception("Cannot extend a constant list")
|
raise TypeError("Cannot extend a constant list")
|
||||||
|
|
||||||
def insert(self, item):
|
def insert(self, item):
|
||||||
raise Exception("Cannot insert into a constant list")
|
raise TypeError("Cannot insert into a constant list")
|
||||||
|
|
||||||
def pop(self, item):
|
def pop(self, item):
|
||||||
raise Exception("Cannot pop from a constant list")
|
raise TypeError("Cannot pop from a constant list")
|
||||||
|
|
||||||
def remove(self, item):
|
def remove(self, item):
|
||||||
raise Exception("Cannot remove from a constant list")
|
raise TypeError("Cannot remove from a constant list")
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
raise Exception("Cannot clear a constant list")
|
raise TypeError("Cannot clear a constant list")
|
||||||
|
|
||||||
def index(self,
|
def index(self,
|
||||||
item: T,
|
item: T,
|
||||||
@ -78,10 +78,10 @@ class ConstantList(Generic[T], Sequence):
|
|||||||
...
|
...
|
||||||
|
|
||||||
def __setitem__(self, item: Union[int, slice], value: Union[T, list[T]]):
|
def __setitem__(self, item: Union[int, slice], value: Union[T, list[T]]):
|
||||||
raise Exception("Cannot set item in a constant list")
|
raise TypeError("Cannot set item in a constant list")
|
||||||
|
|
||||||
def __delitem__(self, item):
|
def __delitem__(self, item):
|
||||||
raise Exception("Cannot delete item from a constant list")
|
raise TypeError("Cannot delete item from a constant list")
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return iter(self._x)
|
return iter(self._x)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user