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
|
return True # Don't actually need to return a form
|
||||||
|
|
||||||
if (
|
if (
|
||||||
not getattr(view, 'get_serializer', None)
|
not getattr(view, 'get_serializer', None) or
|
||||||
or not any(is_form_media_type(parser.media_type) for parser in view.parser_classes)
|
not any(is_form_media_type(parser.media_type) for parser in view.parser_classes)
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -503,8 +503,8 @@ class BrowsableAPIRenderer(BaseRenderer):
|
||||||
# If we're not using content overloading there's no point in
|
# 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
|
# supplying a generic form, as the view won't treat the form's
|
||||||
# value as the content of the request.
|
# value as the content of the request.
|
||||||
if not (api_settings.FORM_CONTENT_OVERRIDE
|
if not (api_settings.FORM_CONTENT_OVERRIDE and
|
||||||
and api_settings.FORM_CONTENTTYPE_OVERRIDE):
|
api_settings.FORM_CONTENTTYPE_OVERRIDE):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Check permissions
|
# Check permissions
|
||||||
|
|
|
@ -383,9 +383,9 @@ class Request(object):
|
||||||
|
|
||||||
# We only need to use form overloading on form POST requests.
|
# We only need to use form overloading on form POST requests.
|
||||||
if (
|
if (
|
||||||
not USE_FORM_OVERLOADING
|
self._request.method != 'POST' or
|
||||||
or self._request.method != 'POST'
|
not USE_FORM_OVERLOADING or
|
||||||
or not is_form_media_type(self._content_type)
|
not is_form_media_type(self._content_type)
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -336,8 +336,8 @@ class Serializer(BaseSerializer):
|
||||||
return OrderedDict([
|
return OrderedDict([
|
||||||
(field_name, field.get_value(self.initial_data))
|
(field_name, field.get_value(self.initial_data))
|
||||||
for field_name, field in self.fields.items()
|
for field_name, field in self.fields.items()
|
||||||
if field.get_value(self.initial_data) is not empty
|
if (field.get_value(self.initial_data) is not empty) and
|
||||||
and not field.read_only
|
not field.read_only
|
||||||
])
|
])
|
||||||
|
|
||||||
return OrderedDict([
|
return OrderedDict([
|
||||||
|
@ -653,8 +653,9 @@ def raise_errors_on_nested_writes(method_name, serializer, validated_data):
|
||||||
# ...
|
# ...
|
||||||
# profile = ProfileSerializer()
|
# profile = ProfileSerializer()
|
||||||
assert not any(
|
assert not any(
|
||||||
isinstance(field, BaseSerializer) and (key in validated_data)
|
isinstance(field, BaseSerializer) and
|
||||||
and isinstance(validated_data[key], (list, dict))
|
(key in validated_data) and
|
||||||
|
isinstance(validated_data[key], (list, dict))
|
||||||
for key, field in serializer.fields.items()
|
for key, field in serializer.fields.items()
|
||||||
), (
|
), (
|
||||||
'The `.{method_name}()` method does not support writable nested'
|
'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')
|
# address = serializer.CharField('profile.address')
|
||||||
assert not any(
|
assert not any(
|
||||||
'.' in field.source and (key in validated_data)
|
'.' in field.source and
|
||||||
and isinstance(validated_data[key], (list, dict))
|
(key in validated_data) and
|
||||||
|
isinstance(validated_data[key], (list, dict))
|
||||||
for key, field in serializer.fields.items()
|
for key, field in serializer.fields.items()
|
||||||
), (
|
), (
|
||||||
'The `.{method_name}()` method does not support writable dotted-source '
|
'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
|
lead = lead + opening
|
||||||
# Keep parentheses at the end only if they're balanced.
|
# Keep parentheses at the end only if they're balanced.
|
||||||
if (
|
if (
|
||||||
middle.endswith(closing)
|
middle.endswith(closing) and
|
||||||
and middle.count(closing) == middle.count(opening) + 1
|
middle.count(closing) == middle.count(opening) + 1
|
||||||
):
|
):
|
||||||
middle = middle[:-len(closing)]
|
middle = middle[:-len(closing)]
|
||||||
trail = closing + trail
|
trail = closing + trail
|
||||||
|
|
|
@ -145,8 +145,8 @@ def _get_reverse_relationships(opts):
|
||||||
related_model=related,
|
related_model=related,
|
||||||
to_many=True,
|
to_many=True,
|
||||||
has_through_model=(
|
has_through_model=(
|
||||||
(getattr(relation.field.rel, 'through', None) is not None)
|
(getattr(relation.field.rel, 'through', None) is not None) and
|
||||||
and not relation.field.rel.through._meta.auto_created
|
not relation.field.rel.through._meta.auto_created
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user