mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
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:
parent
d2d1888217
commit
b25d245b89
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user