Skip to content

Commit a216d02

Browse files
jdufresnetomchristie
authored andcommitted
Merge multiple isinstance() calls to one (encode#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.
1 parent 31bf597 commit a216d02

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rest_framework/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ def to_internal_value(self, data):
16601660
"""
16611661
if html.is_html_input(data):
16621662
data = html.parse_html_list(data, default=[])
1663-
if isinstance(data, type('')) or isinstance(data, Mapping) or not hasattr(data, '__iter__'):
1663+
if isinstance(data, (type(''), Mapping)) or not hasattr(data, '__iter__'):
16641664
self.fail('not_a_list', input_type=type(data).__name__)
16651665
if not self.allow_empty and len(data) == 0:
16661666
self.fail('empty')

0 commit comments

Comments
 (0)