Skip to content

Commit d993018

Browse files
committed
Removed unused imports, pep8 fixes, typo fixes
1 parent 45dc44b commit d993018

13 files changed

+36
-32
lines changed

Diff for: CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Some tips on good issue reporting:
3333
* When describing issues try to phrase your ticket in terms of the *behavior* you think needs changing rather than the *code* you think need changing.
3434
* Search the issue list first for related items, and make sure you're running the latest version of REST framework before reporting an issue.
3535
* If reporting a bug, then try to include a pull request with a failing test case. This will help us quickly identify if there is a valid issue, and make sure that it gets fixed more quickly if there is one.
36-
* Feature requests will often be closed with a recommendation that they be implemented outside of the core REST framework library. Keeping new feature requests implemented as third party libraries allows us to keep down the maintainence overhead of REST framework, so that the focus can be on continued stability, bugfixes, and great documentation.
36+
* Feature requests will often be closed with a recommendation that they be implemented outside of the core REST framework library. Keeping new feature requests implemented as third party libraries allows us to keep down the maintenance overhead of REST framework, so that the focus can be on continued stability, bugfixes, and great documentation.
3737
* Closing an issue doesn't necessarily mean the end of a discussion. If you believe your issue has been closed incorrectly, explain why and we'll consider if it needs to be reopened.
3838

3939
## Triaging issues
@@ -82,7 +82,7 @@ GitHub's documentation for working on pull requests is [available here][pull-req
8282

8383
Always run the tests before submitting pull requests, and ideally run `tox` in order to check that your modifications are compatible with both Python 2 and Python 3, and that they run properly on all supported versions of Django.
8484

85-
Once you've made a pull request take a look at the travis build status in the GitHub interface and make sure the tests are runnning as you'd expect.
85+
Once you've made a pull request take a look at the travis build status in the GitHub interface and make sure the tests are running as you'd expect.
8686

8787
![Travis status][travis-status]
8888

Diff for: rest_framework/authentication.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def authenticate(self, request):
267267
def authenticate_header(self, request):
268268
"""
269269
If permission is denied, return a '401 Unauthorized' response,
270-
with an appropraite 'WWW-Authenticate' header.
270+
with an appropriate 'WWW-Authenticate' header.
271271
"""
272272
return 'OAuth realm="%s"' % self.www_authenticate_realm
273273

Diff for: rest_framework/permissions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def has_object_permission(self, request, view, obj):
184184
if not user.has_perms(perms, obj):
185185
# If the user does not have permissions we need to determine if
186186
# they have read permissions to see 403, or not, and simply see
187-
# a 404 reponse.
187+
# a 404 response.
188188

189189
if request.method in ('GET', 'OPTIONS', 'HEAD'):
190190
# Read permissions already checked and failed, no need

Diff for: rest_framework/relations.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def get_attribute(self, instance):
142142
def get_iterable(self, instance, source_attrs):
143143
# For consistency with `get_attribute` we're using `serializable_value()`
144144
# here. Typically there won't be any difference, but some custom field
145-
# types might return a non-primative value for the pk otherwise.
145+
# types might return a non-primitive value for the pk otherwise.
146146
#
147147
# We could try to get smart with `values_list('pk', flat=True)`, which
148148
# would be better in some case, but would actually end up with *more*

Diff for: rest_framework/renderers.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ def get_template_names(self, response, view):
282282
return view.get_template_names()
283283
elif hasattr(view, 'template_name'):
284284
return [view.template_name]
285-
raise ImproperlyConfigured('Returned a template response with no `template_name` attribute set on either the view or response')
285+
raise ImproperlyConfigured(
286+
'Returned a template response with no `template_name` attribute set on either the view or response'
287+
)
286288

287289
def get_exception_template(self, response):
288290
template_names = [name % {'status_code': response.status_code}

Diff for: rest_framework/serializers.py

+15-18
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,13 @@
1010
2. The process of marshalling between python primitives and request and
1111
response content is handled by parsers and renderers.
1212
"""
13-
from django.core.exceptions import ImproperlyConfigured
14-
from django.core.exceptions import ValidationError as DjangoValidationError
13+
import warnings
14+
1515
from django.db import models
1616
from django.db.models.fields import FieldDoesNotExist
17-
from django.utils import six
1817
from django.utils.translation import ugettext_lazy as _
19-
from rest_framework.compat import OrderedDict
20-
from rest_framework.exceptions import ValidationError
21-
from rest_framework.fields import empty, set_value, Field, SkipField
22-
from rest_framework.settings import api_settings
23-
from rest_framework.utils import html, model_meta, representation
18+
19+
from rest_framework.utils import model_meta
2420
from rest_framework.utils.field_mapping import (
2521
get_url_kwargs, get_field_kwargs,
2622
get_relation_kwargs, get_nested_relation_kwargs,
@@ -33,9 +29,7 @@
3329
UniqueForDateValidator, UniqueForMonthValidator, UniqueForYearValidator,
3430
UniqueTogetherValidator
3531
)
36-
import copy
37-
import inspect
38-
import warnings
32+
3933

4034
# Note: We do the following so that users of the framework can use this style:
4135
#
@@ -65,6 +59,7 @@ class BaseSerializer(Field):
6559
The BaseSerializer class provides a minimal class which may be used
6660
for writing custom serializer implementations.
6761
"""
62+
6863
def __init__(self, instance=None, data=None, **kwargs):
6964
self.instance = instance
7065
self._initial_data = data
@@ -245,7 +240,7 @@ def fields(self):
245240
"""
246241
A dictionary of {field_name: field_instance}.
247242
"""
248-
# `fields` is evalutated lazily. We do this to ensure that we don't
243+
# `fields` is evaluated lazily. We do this to ensure that we don't
249244
# have issues importing modules that use ModelSerializers as fields,
250245
# even if Django's app-loading stage has not yet run.
251246
if not hasattr(self, '_fields'):
@@ -343,7 +338,7 @@ def run_validation(self, data=empty):
343338
# Normally you should raise `serializers.ValidationError`
344339
# inside your codebase, but we handle Django's validation
345340
# exception class as well for simpler compat.
346-
# Eg. Calling Model.clean() explictily inside Serializer.validate()
341+
# Eg. Calling Model.clean() explicitly inside Serializer.validate()
347342
raise ValidationError({
348343
api_settings.NON_FIELD_ERRORS_KEY: list(exc.messages)
349344
})
@@ -576,7 +571,7 @@ class ModelSerializer(Serializer):
576571
577572
The process of automatically determining a set of serializer fields
578573
based on the model fields is reasonably complex, but you almost certainly
579-
don't need to dig into the implemention.
574+
don't need to dig into the implementation.
580575
581576
If the `ModelSerializer` class *doesn't* generate the set of fields that
582577
you need you should either declare the extra/differing fields explicitly on
@@ -636,7 +631,7 @@ def create(self, validated_data):
636631
isinstance(field, BaseSerializer) and (key in validated_attrs)
637632
for key, field in self.fields.items()
638633
), (
639-
'The `.create()` method does not suport nested writable fields '
634+
'The `.create()` method does not support nested writable fields '
640635
'by default. Write an explicit `.create()` method for serializer '
641636
'`%s.%s`, or set `read_only=True` on nested serializer fields.' %
642637
(self.__class__.__module__, self.__class__.__name__)
@@ -684,7 +679,7 @@ def update(self, instance, validated_data):
684679
isinstance(field, BaseSerializer) and (key in validated_attrs)
685680
for key, field in self.fields.items()
686681
), (
687-
'The `.update()` method does not suport nested writable fields '
682+
'The `.update()` method does not support nested writable fields '
688683
'by default. Write an explicit `.update()` method for serializer '
689684
'`%s.%s`, or set `read_only=True` on nested serializer fields.' %
690685
(self.__class__.__module__, self.__class__.__name__)
@@ -824,7 +819,7 @@ def get_fields(self):
824819
# applied, we can add the extra 'required=...' or 'default=...'
825820
# arguments that are appropriate to these fields, or add a `HiddenField` for it.
826821
for unique_constraint_name in unique_constraint_names:
827-
# Get the model field that is refered too.
822+
# Get the model field that is referred too.
828823
unique_constraint_field = model._meta.get_field(unique_constraint_name)
829824

830825
if getattr(unique_constraint_field, 'auto_now_add', None):
@@ -907,7 +902,7 @@ def get_fields(self):
907902
)
908903

909904
# Check that any fields declared on the class are
910-
# also explicity included in `Meta.fields`.
905+
# also explicitly included in `Meta.fields`.
911906
missing_fields = set(declared_fields.keys()) - set(fields)
912907
if missing_fields:
913908
missing_field = list(missing_fields)[0]
@@ -1001,6 +996,7 @@ class NestedSerializer(ModelSerializer):
1001996
class Meta:
1002997
model = relation_info.related
1003998
depth = nested_depth
999+
10041000
return NestedSerializer
10051001

10061002

@@ -1027,4 +1023,5 @@ class NestedSerializer(HyperlinkedModelSerializer):
10271023
class Meta:
10281024
model = relation_info.related
10291025
depth = nested_depth
1026+
10301027
return NestedSerializer

Diff for: rest_framework/settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
'DEFAULT_CONTENT_NEGOTIATION_CLASS': 'rest_framework.negotiation.DefaultContentNegotiation',
4848
'DEFAULT_METADATA_CLASS': 'rest_framework.metadata.SimpleMetadata',
4949

50-
# Genric view behavior
50+
# Generic view behavior
5151
'DEFAULT_MODEL_SERIALIZER_CLASS': 'rest_framework.serializers.ModelSerializer',
5252
'DEFAULT_PAGINATION_SERIALIZER_CLASS': 'rest_framework.pagination.PaginationSerializer',
5353
'DEFAULT_FILTER_BACKENDS': (),

Diff for: rest_framework/validators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
This gives us better separation of concerns, allows us to use single-step
66
object creation, and makes it possible to switch between using the implicit
7-
`ModelSerializer` class and an equivelent explicit `Serializer` class.
7+
`ModelSerializer` class and an equivalent explicit `Serializer` class.
88
"""
99
from django.utils.translation import ugettext_lazy as _
1010
from rest_framework.exceptions import ValidationError

Diff for: rest_framework/viewsets.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def as_view(cls, actions=None, **initkwargs):
4444
instantiated view, we need to totally reimplement `.as_view`,
4545
and slightly modify the view function that is created and returned.
4646
"""
47-
# The suffix initkwarg is reserved for identifing the viewset type
47+
# The suffix initkwarg is reserved for identifying the viewset type
4848
# eg. 'List' or 'Instance'.
4949
cls.suffix = None
5050

@@ -98,12 +98,12 @@ def view(request, *args, **kwargs):
9898
view.suffix = initkwargs.get('suffix', None)
9999
return csrf_exempt(view)
100100

101-
def initialize_request(self, request, *args, **kargs):
101+
def initialize_request(self, request, *args, **kwargs):
102102
"""
103103
Set the `.action` attribute on the view,
104104
depending on the request method.
105105
"""
106-
request = super(ViewSetMixin, self).initialize_request(request, *args, **kargs)
106+
request = super(ViewSetMixin, self).initialize_request(request, *args, **kwargs)
107107
self.action = self.action_map.get(request.method.lower())
108108
return request
109109

Diff for: runtests.py

+5
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,29 @@
1717

1818
sys.path.append(os.path.dirname(__file__))
1919

20+
2021
def exit_on_failure(ret, message=None):
2122
if ret:
2223
sys.exit(ret)
2324

25+
2426
def flake8_main(args):
2527
print('Running flake8 code linting')
2628
ret = subprocess.call(['flake8'] + args)
2729
print('flake8 failed' if ret else 'flake8 passed')
2830
return ret
2931

32+
3033
def split_class_and_function(string):
3134
class_string, function_string = string.split('.', 1)
3235
return "%s and %s" % (class_string, function_string)
3336

37+
3438
def is_function(string):
3539
# `True` if it looks like a test function is included in the string.
3640
return string.startswith('test_') or '.test_' in string
3741

42+
3843
def is_class(string):
3944
# `True` if first character is uppercase - assume it's a class name.
4045
return string[0] == string[0].upper()

Diff for: tests/test_multitable_inheritance.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Meta:
3131

3232

3333
# Tests
34-
class IneritedModelSerializationTests(TestCase):
34+
class InheritedModelSerializationTests(TestCase):
3535

3636
def test_multitable_inherited_model_fields_as_expected(self):
3737
"""

Diff for: tests/test_request.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def post(self, request):
187187
if request.POST.get('example') is not None:
188188
return Response(status=status.HTTP_200_OK)
189189

190-
return Response(status=status.INTERNAL_SERVER_ERROR)
190+
return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR)
191191

192192
urlpatterns = patterns(
193193
'',

Diff for: tests/test_validators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def test_unique_together_is_required(self):
148148
def test_ignore_excluded_fields(self):
149149
"""
150150
When model fields are not included in a serializer, then uniqueness
151-
validtors should not be added for that field.
151+
validators should not be added for that field.
152152
"""
153153
class ExcludedFieldSerializer(serializers.ModelSerializer):
154154
class Meta:

0 commit comments

Comments
 (0)