mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +03:00
Fixes for latest pep8 updates. Refs #2563.
This commit is contained in:
parent
76fe710c0d
commit
dbd2352165
|
@ -458,8 +458,8 @@ class BrowsableAPIRenderer(BaseRenderer):
|
|||
return True # Don't actually need to return a form
|
||||
|
||||
if (
|
||||
not getattr(view, 'get_serializer', None)
|
||||
or not any(is_form_media_type(parser.media_type) for parser in view.parser_classes)
|
||||
not getattr(view, 'get_serializer', None) or
|
||||
not any(is_form_media_type(parser.media_type) for parser in view.parser_classes)
|
||||
):
|
||||
return
|
||||
|
||||
|
@ -503,8 +503,8 @@ class BrowsableAPIRenderer(BaseRenderer):
|
|||
# If we're not using content overloading there's no point in
|
||||
# supplying a generic form, as the view won't treat the form's
|
||||
# value as the content of the request.
|
||||
if not (api_settings.FORM_CONTENT_OVERRIDE
|
||||
and api_settings.FORM_CONTENTTYPE_OVERRIDE):
|
||||
if not (api_settings.FORM_CONTENT_OVERRIDE and
|
||||
api_settings.FORM_CONTENTTYPE_OVERRIDE):
|
||||
return None
|
||||
|
||||
# Check permissions
|
||||
|
|
|
@ -383,9 +383,9 @@ class Request(object):
|
|||
|
||||
# We only need to use form overloading on form POST requests.
|
||||
if (
|
||||
not USE_FORM_OVERLOADING
|
||||
or self._request.method != 'POST'
|
||||
or not is_form_media_type(self._content_type)
|
||||
self._request.method != 'POST' or
|
||||
not USE_FORM_OVERLOADING or
|
||||
not is_form_media_type(self._content_type)
|
||||
):
|
||||
return
|
||||
|
||||
|
|
|
@ -336,8 +336,8 @@ class Serializer(BaseSerializer):
|
|||
return OrderedDict([
|
||||
(field_name, field.get_value(self.initial_data))
|
||||
for field_name, field in self.fields.items()
|
||||
if field.get_value(self.initial_data) is not empty
|
||||
and not field.read_only
|
||||
if (field.get_value(self.initial_data) is not empty) and
|
||||
not field.read_only
|
||||
])
|
||||
|
||||
return OrderedDict([
|
||||
|
@ -653,8 +653,9 @@ def raise_errors_on_nested_writes(method_name, serializer, validated_data):
|
|||
# ...
|
||||
# profile = ProfileSerializer()
|
||||
assert not any(
|
||||
isinstance(field, BaseSerializer) and (key in validated_data)
|
||||
and isinstance(validated_data[key], (list, dict))
|
||||
isinstance(field, BaseSerializer) and
|
||||
(key in validated_data) and
|
||||
isinstance(validated_data[key], (list, dict))
|
||||
for key, field in serializer.fields.items()
|
||||
), (
|
||||
'The `.{method_name}()` method does not support writable nested'
|
||||
|
@ -673,8 +674,9 @@ def raise_errors_on_nested_writes(method_name, serializer, validated_data):
|
|||
# ...
|
||||
# address = serializer.CharField('profile.address')
|
||||
assert not any(
|
||||
'.' in field.source and (key in validated_data)
|
||||
and isinstance(validated_data[key], (list, dict))
|
||||
'.' in field.source and
|
||||
(key in validated_data) and
|
||||
isinstance(validated_data[key], (list, dict))
|
||||
for key, field in serializer.fields.items()
|
||||
), (
|
||||
'The `.{method_name}()` method does not support writable dotted-source '
|
||||
|
|
|
@ -162,8 +162,8 @@ def urlize_quoted_links(text, trim_url_limit=None, nofollow=True, autoescape=Tru
|
|||
lead = lead + opening
|
||||
# Keep parentheses at the end only if they're balanced.
|
||||
if (
|
||||
middle.endswith(closing)
|
||||
and middle.count(closing) == middle.count(opening) + 1
|
||||
middle.endswith(closing) and
|
||||
middle.count(closing) == middle.count(opening) + 1
|
||||
):
|
||||
middle = middle[:-len(closing)]
|
||||
trail = closing + trail
|
||||
|
|
|
@ -145,8 +145,8 @@ def _get_reverse_relationships(opts):
|
|||
related_model=related,
|
||||
to_many=True,
|
||||
has_through_model=(
|
||||
(getattr(relation.field.rel, 'through', None) is not None)
|
||||
and not relation.field.rel.through._meta.auto_created
|
||||
(getattr(relation.field.rel, 'through', None) is not None) and
|
||||
not relation.field.rel.through._meta.auto_created
|
||||
)
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user