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

* Merge multiple isinstance() calls to one

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

* Fix `)` mismatch

Fix `)` mismatch
This commit is contained in:
Patrickcai 2019-03-22 20:29:45 +08:00 committed by Tom Christie
parent d2d1888217
commit b25d245b89

View File

@ -106,8 +106,7 @@ def get_field_kwargs(field_name, model_field):
if model_field.null and not isinstance(model_field, models.NullBooleanField):
kwargs['allow_null'] = True
if model_field.blank and (isinstance(model_field, models.CharField) or
isinstance(model_field, models.TextField)):
if model_field.blank and (isinstance(model_field, (models.CharField, models.TextField))):
kwargs['allow_blank'] = True
if isinstance(model_field, models.FilePathField):
@ -193,9 +192,7 @@ def get_field_kwargs(field_name, model_field):
# Ensure that max_length is passed explicitly as a keyword arg,
# rather than as a validator.
max_length = getattr(model_field, 'max_length', None)
if max_length is not None and (isinstance(model_field, models.CharField) or
isinstance(model_field, models.TextField) or
isinstance(model_field, models.FileField)):
if max_length is not None and (isinstance(model_field, (models.CharField, models.TextField, models.FileField))):
kwargs['max_length'] = max_length
validator_kwarg = [
validator for validator in validator_kwarg