Merge multiple isinstance() calls to one (#6481)

https://docs.python.org/3/library/functions.html#isinstance

> If classinfo is a tuple of type objects (or recursively, other such
> tuples), return true if object is an instance of any of the types.
This commit is contained in:
Jon Dufresne 2019-03-02 12:48:03 -08:00 committed by Tom Christie
parent 31bf597081
commit a216d02ce0

View File

@ -1660,7 +1660,7 @@ class ListField(Field):
"""
if html.is_html_input(data):
data = html.parse_html_list(data, default=[])
if isinstance(data, type('')) or isinstance(data, Mapping) or not hasattr(data, '__iter__'):
if isinstance(data, (type(''), Mapping)) or not hasattr(data, '__iter__'):
self.fail('not_a_list', input_type=type(data).__name__)
if not self.allow_empty and len(data) == 0:
self.fail('empty')