@@ -104,8 +104,7 @@ def get_attribute(instance, attrs):
104
104
# If we raised an Attribute or KeyError here it'd get treated
105
105
# as an omitted field in `Field.get_attribute()`. Instead we
106
106
# raise a ValueError to ensure the exception is not masked.
107
- raise ValueError (
108
- 'Exception raised in callable attribute "{}"; original exception was: {}' .format (attr , exc ))
107
+ raise ValueError ('Exception raised in callable attribute "{}"; original exception was: {}' .format (attr , exc ))
109
108
110
109
return instance
111
110
@@ -182,7 +181,6 @@ def iter_options(grouped_choices, cutoff=None, cutoff_text=None):
182
181
"""
183
182
Helper function for options and option groups in templates.
184
183
"""
185
-
186
184
class StartOptionGroup :
187
185
start_option_group = True
188
186
end_option_group = False
@@ -368,10 +366,10 @@ def bind(self, field_name, parent):
368
366
# 'source' argument has been used. For example:
369
367
# my_field = serializer.CharField(source='my_field')
370
368
assert self .source != field_name , (
371
- "It is redundant to specify `source='%s'` on field '%s' in "
372
- "serializer '%s', because it is the same as the field name. "
373
- "Remove the `source` keyword argument." %
374
- (field_name , self .__class__ .__name__ , parent .__class__ .__name__ )
369
+ "It is redundant to specify `source='%s'` on field '%s' in "
370
+ "serializer '%s', because it is the same as the field name. "
371
+ "Remove the `source` keyword argument." %
372
+ (field_name , self .__class__ .__name__ , parent .__class__ .__name__ )
375
373
)
376
374
377
375
self .field_name = field_name
@@ -796,8 +794,7 @@ def __init__(self, allow_unicode=False, **kwargs):
796
794
super ().__init__ (** kwargs )
797
795
self .allow_unicode = allow_unicode
798
796
if self .allow_unicode :
799
- validator = RegexValidator (re .compile (r'^[-\w]+\Z' , re .UNICODE ),
800
- message = self .error_messages ['invalid_unicode' ])
797
+ validator = RegexValidator (re .compile (r'^[-\w]+\Z' , re .UNICODE ), message = self .error_messages ['invalid_unicode' ])
801
798
else :
802
799
validator = RegexValidator (re .compile (r'^[-a-zA-Z0-9_]+$' ), message = self .error_messages ['invalid' ])
803
800
self .validators .append (validator )
@@ -997,7 +994,7 @@ def __init__(self, max_digits, decimal_places, coerce_to_string=None, max_value=
997
994
if rounding is not None :
998
995
valid_roundings = [v for k , v in vars (decimal ).items () if k .startswith ('ROUND_' )]
999
996
assert rounding in valid_roundings , (
1000
- 'Invalid rounding option %s. Valid values for rounding are: %s' % (rounding , valid_roundings ))
997
+ 'Invalid rounding option %s. Valid values for rounding are: %s' % (rounding , valid_roundings ))
1001
998
self .rounding = rounding
1002
999
1003
1000
def validate_empty_values (self , data ):
@@ -1735,7 +1732,6 @@ def __new__(cls, value):
1735
1732
ret = str .__new__ (cls , value )
1736
1733
ret .is_json_string = True
1737
1734
return ret
1738
-
1739
1735
return JSONString (dictionary [self .field_name ])
1740
1736
return dictionary .get (self .field_name , empty )
1741
1737
@@ -1789,7 +1785,6 @@ class HiddenField(Field):
1789
1785
constraint on a pair of fields, as we need some way to include the date in
1790
1786
the validated data.
1791
1787
"""
1792
-
1793
1788
def __init__ (self , ** kwargs ):
1794
1789
assert 'default' in kwargs , 'default is a required argument.'
1795
1790
kwargs ['write_only' ] = True
@@ -1819,7 +1814,6 @@ class ExampleSerializer(Serializer):
1819
1814
def get_extra_info(self, obj):
1820
1815
return ... # Calculate some data to return.
1821
1816
"""
1822
-
1823
1817
def __init__ (self , method_name = None , ** kwargs ):
1824
1818
self .method_name = method_name
1825
1819
kwargs ['source' ] = '*'
0 commit comments