Skip to content

Commit dabe447

Browse files
alexwlchanagjohnson
authored andcommitted
Docstring/PEP 257 fixes for the restapi app (#2825)
1 parent 6d8e3f9 commit dabe447

File tree

5 files changed

+13
-18
lines changed

5 files changed

+13
-18
lines changed

readthedocs/restapi/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717

1818
class DrfJsonSerializer(serialize.JsonSerializer):
19-
'''Additional serialization help from the DRF parser/renderer'''
19+
20+
"""Additional serialization help from the DRF parser/renderer"""
21+
2022
key = 'json-drf'
2123

2224
def loads(self, data):

readthedocs/restapi/permissions.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
class IsOwner(permissions.BasePermission):
66

7-
"""
8-
Custom permission to only allow owners of an object to edit it.
9-
"""
7+
"""Custom permission to only allow owners of an object to edit it."""
108

119
def has_object_permission(self, request, view, obj):
1210
# Write permissions are only allowed to the owner of the snippet
@@ -24,9 +22,7 @@ def has_object_permission(self, request, view, comment):
2422

2523
class RelatedProjectIsOwner(permissions.BasePermission):
2624

27-
"""
28-
Custom permission to only allow owners of an object to edit it.
29-
"""
25+
"""Custom permission to only allow owners of an object to edit it."""
3026

3127
def has_permission(self, request, view):
3228
return (request.method in permissions.SAFE_METHODS)
@@ -41,12 +37,14 @@ def has_object_permission(self, request, view, obj):
4137

4238
class APIPermission(permissions.IsAuthenticatedOrReadOnly):
4339

44-
'''
40+
"""
41+
Control users access to the API.
42+
4543
This permission should allow authenticated users readonly access to the API,
4644
and allow admin users write access. This should be used on API resources
4745
that need to implement write operations to resources that were based on the
4846
ReadOnlyViewSet
49-
'''
47+
"""
5048

5149
def has_permission(self, request, view):
5250
has_perm = super(APIPermission, self).has_permission(request, view)

readthedocs/restapi/utils.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212

1313
def sync_versions(project, versions, type):
14-
"""
15-
Update the database with the current versions from the repository.
16-
"""
14+
"""Update the database with the current versions from the repository."""
1715
# Bookkeeping for keeping tag/branch identifies correct
1816
verbose_names = [v['verbose_name'] for v in versions]
1917
project.versions.filter(verbose_name__in=verbose_names).update(type=type)
@@ -58,9 +56,7 @@ def sync_versions(project, versions, type):
5856

5957

6058
def delete_versions(project, version_data):
61-
"""
62-
Delete all versions not in the current repo.
63-
"""
59+
"""Delete all versions not in the current repo."""
6460
current_versions = []
6561
if 'tags' in version_data:
6662
for version in version_data['tags']:

readthedocs/restapi/views/core_views.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
def cname(request):
2323
"""
2424
Get the slug that a particular hostname resolves to.
25+
2526
This is useful for debugging your DNS settings,
2627
or for getting the backing project name on Read the Docs for a URL.
2728

readthedocs/restapi/views/model_views.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ def get_queryset(self):
4545

4646
@decorators.detail_route()
4747
def valid_versions(self, request, **kwargs):
48-
"""
49-
Maintain state of versions that are wanted.
50-
"""
48+
"""Maintain state of versions that are wanted."""
5149
project = get_object_or_404(
5250
Project.objects.api(self.request.user), pk=kwargs['pk'])
5351
if not project.num_major or not project.num_minor or not project.num_point:

0 commit comments

Comments
 (0)