From 49bcd893e753d89a1c2a95a1c2649819309c1e1b Mon Sep 17 00:00:00 2001 From: "ZiTian.Zhao" Date: Mon, 4 Aug 2025 13:14:49 +0800 Subject: [PATCH] [refactor] improve ConstantList exception specificity (#22156) Signed-off-by: zitian.zhao --- vllm/v1/utils.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/vllm/v1/utils.py b/vllm/v1/utils.py index d0175695c1d0..b5750c82db02 100644 --- a/vllm/v1/utils.py +++ b/vllm/v1/utils.py @@ -34,22 +34,22 @@ class ConstantList(Generic[T], Sequence): self._x = x def append(self, item): - raise Exception("Cannot append to a constant list") + raise TypeError("Cannot append to a constant list") def extend(self, item): - raise Exception("Cannot extend a constant list") + raise TypeError("Cannot extend a constant list") def insert(self, item): - raise Exception("Cannot insert into a constant list") + raise TypeError("Cannot insert into a constant list") def pop(self, item): - raise Exception("Cannot pop from a constant list") + raise TypeError("Cannot pop from a constant list") def remove(self, item): - raise Exception("Cannot remove from a constant list") + raise TypeError("Cannot remove from a constant list") def clear(self): - raise Exception("Cannot clear a constant list") + raise TypeError("Cannot clear a constant list") def index(self, item: T, @@ -78,10 +78,10 @@ class ConstantList(Generic[T], Sequence): ... 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): - raise Exception("Cannot delete item from a constant list") + raise TypeError("Cannot delete item from a constant list") def __iter__(self): return iter(self._x)