@@ -49,7 +49,10 @@ def _log_insecure_serialization_warning():
4949 "VLLM_ALLOW_INSECURE_SERIALIZATION=1" )
5050
5151
52- def _typestr (t : type ):
52+ def _typestr (val : Any ) -> Optional [tuple [str , str ]]:
53+ if val is None :
54+ return None
55+ t = type (val )
5356 return t .__module__ , t .__qualname__
5457
5558
@@ -131,14 +134,13 @@ def enc_hook(self, obj: Any) -> Any:
131134
132135 if isinstance (obj , UtilityResult ):
133136 result = obj .result
134- if not envs .VLLM_ALLOW_INSECURE_SERIALIZATION or result is None :
137+ if not envs .VLLM_ALLOW_INSECURE_SERIALIZATION :
135138 return None , result
136139 # Since utility results are not strongly typed, we also encode
137140 # the type (or a list of types in the case it's a list) to
138141 # help with correct msgspec deserialization.
139- cls = result .__class__
140- return _typestr (cls ) if cls is not list else [
141- _typestr (type (v )) for v in result
142+ return _typestr (result ) if type (result ) is not list else [
143+ _typestr (v ) for v in result
142144 ], result
143145
144146 if not envs .VLLM_ALLOW_INSECURE_SERIALIZATION :
@@ -277,7 +279,9 @@ def _decode_utility_result(self, obj: Any) -> UtilityResult:
277279 ]
278280 return UtilityResult (result )
279281
280- def _convert_result (self , result_type : Sequence [str ], result : Any ):
282+ def _convert_result (self , result_type : Sequence [str ], result : Any ) -> Any :
283+ if result_type is None :
284+ return result
281285 mod_name , name = result_type
282286 mod = importlib .import_module (mod_name )
283287 result_type = getattr (mod , name )
0 commit comments