From a216d02ce0661510d456cfd327fadc3acb9ec960 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sat, 2 Mar 2019 12:48:03 -0800 Subject: [PATCH] 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. --- rest_framework/fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 1b8387714..b5fafeaa3 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -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')