File tree 1 file changed +8
-1
lines changed
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ class ResponseIterator:
31
31
response (requests.Response): An API response object.
32
32
response_message_cls (Union[proto.Message, google.protobuf.message.Message]): A response
33
33
class expected to be returned from an API.
34
+
35
+ Raises:
36
+ ValueError: If `response_message_cls` is not a subclass of `proto.Message` or `google.protobuf.message.Message`.
34
37
"""
35
38
36
39
def __init__ (
@@ -116,8 +119,12 @@ def _grab(self):
116
119
# Add extra quotes to make json.loads happy.
117
120
if issubclass (self ._response_message_cls , proto .Message ):
118
121
return self ._response_message_cls .from_json (self ._ready_objs .popleft ())
119
- else :
122
+ elif issubclass ( self . _response_message_cls , google . protobuf . message . Message ) :
120
123
return Parse (self ._ready_objs .popleft (), self ._response_message_cls ())
124
+ else :
125
+ raise ValueError (
126
+ "Response message class must be a subclass of proto.Message or google.protobuf.message.Message."
127
+ )
121
128
122
129
def __iter__ (self ):
123
130
return self
You can’t perform that action at this time.
0 commit comments