Skip to content

Commit 7dcc593

Browse files
author
Kevin Burke
committed
slight refactoring to avoid duplication
1 parent 9e7cbda commit 7dcc593

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

flask_restful/fields.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,15 @@ def output(self, key, obj):
134134
class List(Raw):
135135
def __init__(self, cls_or_instance, **kwargs):
136136
super(List, self).__init__(**kwargs)
137+
error_msg = ("The type of the list elements must be a subclass of "
138+
"flask_restful.fields.Raw")
137139
if isinstance(cls_or_instance, type):
138140
if not issubclass(cls_or_instance, Raw):
139-
raise MarshallingException("The type of the list elements "
140-
"must be a subclass of "
141-
"flask_restful.fields.Raw")
141+
raise MarshallingException(error_msg)
142142
self.container = cls_or_instance()
143143
else:
144144
if not isinstance(cls_or_instance, Raw):
145-
raise MarshallingException("The instances of the list "
146-
"elements must be of type "
147-
"flask_restful.fields.Raw")
145+
raise MarshallingException(error_msg)
148146
self.container = cls_or_instance
149147

150148
def output(self, key, data):

0 commit comments

Comments
 (0)