Skip to content

Commit b153e28

Browse files
authored
Lint (pep257: D415) (readthedocs#5892)
Lint (pep257: D415)
2 parents a92c21d + a4b3696 commit b153e28

File tree

16 files changed

+60
-31
lines changed

16 files changed

+60
-31
lines changed

readthedocs/api/v2/views/integrations.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ def is_payload_valid(self):
223223
GitHub use a HMAC hexdigest hash to sign the payload.
224224
225225
It is sent in the request's header.
226-
See https://developer.github.com/webhooks/securing/
226+
227+
See https://developer.github.com/webhooks/securing/.
227228
"""
228229
signature = self.request.META.get(GITHUB_SIGNATURE_HEADER)
229230
secret = self.get_integration().secret
@@ -245,7 +246,7 @@ def is_payload_valid(self):
245246

246247
@staticmethod
247248
def get_digest(secret, msg):
248-
"""Get a HMAC digest of `msg` using `secret.`"""
249+
"""Get a HMAC digest of `msg` using `secret`."""
249250
digest = hmac.new(
250251
secret.encode(),
251252
msg=msg.encode(),

readthedocs/builds/querysets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class BuildQuerySet(SettingsOverrideObject):
121121

122122
class RelatedBuildQuerySetBase(models.QuerySet):
123123

124-
"""For models with association to a project through :py:class:`Build`"""
124+
"""For models with association to a project through :py:class:`Build`."""
125125

126126
use_for_related_fields = True
127127

readthedocs/builds/storage.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class BuildMediaStorageMixin:
1313

1414
"""
15-
A mixin for Storage classes needed to write build artifacts
15+
A mixin for Storage classes needed to write build artifacts.
1616
1717
This adds and modifies some functionality to Django's File Storage API.
1818
By default, classes mixing this in will now overwrite files by default instead
@@ -24,7 +24,11 @@ class BuildMediaStorageMixin:
2424

2525
@staticmethod
2626
def _dirpath(path):
27-
"""It may just be Azure, but for listdir to work correctly, the path must end in '/'"""
27+
"""
28+
Make the path to end with `/`.
29+
30+
It may just be Azure, but for listdir to work correctly, this is needed.
31+
"""
2832
path = str(path)
2933
if not path.endswith('/'):
3034
path += '/'
@@ -33,7 +37,7 @@ def _dirpath(path):
3337

3438
def get_available_name(self, name, max_length=None):
3539
"""
36-
Overrides Django's storage implementation to always return the passed name (overwrite)
40+
Overrides Django's storage to always return the passed name (overwrite).
3741
3842
By default, Django will not overwrite files even if the same name is specified.
3943
This changes that functionality so that the default is to use the same name and overwrite
@@ -43,7 +47,7 @@ def get_available_name(self, name, max_length=None):
4347

4448
def delete_directory(self, path):
4549
"""
46-
Delete all files under a certain path from storage
50+
Delete all files under a certain path from storage.
4751
4852
Many storage backends (S3, Azure storage) don't care about "directories".
4953
The directory effectively doesn't exist if there are no files in it.
@@ -67,7 +71,7 @@ def delete_directory(self, path):
6771

6872
def copy_directory(self, source, destination):
6973
"""
70-
Copy a directory recursively to storage
74+
Copy a directory recursively to storage.
7175
7276
:param source: the source path on the local disk
7377
:param destination: the destination path in storage
@@ -86,11 +90,11 @@ def copy_directory(self, source, destination):
8690

8791
class BuildMediaFileSystemStorage(BuildMediaStorageMixin, FileSystemStorage):
8892

89-
"""Storage subclass that writes build artifacts under MEDIA_ROOT"""
93+
"""Storage subclass that writes build artifacts under MEDIA_ROOT."""
9094

9195
def get_available_name(self, name, max_length=None):
9296
"""
93-
A hack to overwrite by default with the FileSystemStorage
97+
A hack to overwrite by default with the FileSystemStorage.
9498
9599
After upgrading to Django 2.2, this method can be removed
96100
because subclasses can set OS_OPEN_FLAGS such that FileSystemStorage._save
@@ -103,7 +107,11 @@ def get_available_name(self, name, max_length=None):
103107
return name
104108

105109
def listdir(self, path):
106-
"""Return empty lists for nonexistent directories (as cloud storages do)"""
110+
"""
111+
Return empty lists for nonexistent directories.
112+
113+
This mimics what cloud storages do.
114+
"""
107115
if not self.exists(path):
108116
return [], []
109117
return super().listdir(path)

readthedocs/builds/syncers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def copy(cls, path, target, is_file=False, **kwargs):
2929

3030
class NullSyncer:
3131

32-
"""A syncer that doesn't actually do anything"""
32+
"""A syncer that doesn't actually do anything."""
3333

3434
@classmethod
3535
def copy(cls, path, target, is_file=False, **kwargs):

readthedocs/core/templatetags/core_tags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def readthedocs_version():
117117
@register.filter
118118
def escapejson(data, indent=None):
119119
"""
120-
Escape JSON correctly for inclusion in Django templates
120+
Escape JSON correctly for inclusion in Django templates.
121121
122122
This code was mostly taken from Django's implementation
123123
https://docs.djangoproject.com/en/2.2/ref/templates/builtins/#json-script

readthedocs/core/views/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""
2-
Core views, including the main homepage,
2+
Core views.
33
4-
documentation and header rendering, and server errors.
4+
Including the main homepage, documentation and header rendering,
5+
and server errors.
56
"""
67

78
import os

readthedocs/oauth/querysets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class RelatedUserQuerySetBase(models.QuerySet):
1111

12-
"""For models with relations through :py:class:`User`"""
12+
"""For models with relations through :py:class:`User`."""
1313

1414
def api(self, user=None):
1515
"""Return objects for user."""

readthedocs/projects/models.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,11 @@ def remove_subproject(self, child):
10351035
ProjectRelationship.objects.filter(parent=self, child=child).delete()
10361036

10371037
def get_parent_relationship(self):
1038-
"""Get the parent project relationship or None if this is a top level project"""
1038+
"""
1039+
Get parent project relationship.
1040+
1041+
It returns ``None`` if this is a top level project.
1042+
"""
10391043
if hasattr(self, '_superprojects'):
10401044
# Cached parent project relationship
10411045
if self._superprojects:
@@ -1150,7 +1154,7 @@ def has_feature(self, feature_id):
11501154

11511155
@property
11521156
def show_advertising(self):
1153-
"""Whether this project is ad-free (don't access the database)"""
1157+
"""Whether this project is ad-free (don't access the database)."""
11541158
return not self.ad_free
11551159

11561160
@property

readthedocs/projects/querysets.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ def is_active(self, project):
7676

7777
def prefetch_latest_build(self):
7878
"""
79-
For a given queryset of projects, prefetch the latest build for each project
79+
Prefetch "latest build" for each project.
8080
81-
This should come after any filtering.
81+
.. note::
82+
83+
This should come after any filtering.
8284
"""
8385
from readthedocs.builds.models import Build
8486

@@ -98,7 +100,7 @@ def prefetch_latest_build(self):
98100
# Aliases
99101

100102
def dashboard(self, user=None):
101-
"""Get the projects for this user including the latest build"""
103+
"""Get the projects for this user including the latest build."""
102104
return self.for_admin_user(user).prefetch_latest_build()
103105

104106
def api(self, user=None, detail=True):

readthedocs/projects/tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ def store_build_artifacts(
703703
epub=False,
704704
):
705705
"""
706-
Save build artifacts to "storage" using Django's storage API
706+
Save build artifacts to "storage" using Django's storage API.
707707
708708
The storage could be local filesystem storage OR cloud blob storage
709709
such as S3, Azure storage or Google Cloud Storage.
@@ -1688,7 +1688,7 @@ def remove_dirs(paths):
16881688
@app.task(queue='web')
16891689
def remove_build_storage_paths(paths):
16901690
"""
1691-
Remove artifacts from build media storage (cloud or local storage)
1691+
Remove artifacts from build media storage (cloud or local storage).
16921692
16931693
:param paths: list of paths in build media storage to delete
16941694
"""

readthedocs/projects/views/public.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ def get_context_data(self, **kwargs):
7070

7171

7272
def project_redirect(request, invalid_project_slug):
73-
"""Redirect old project slugs that had underscores which are no longer allowed"""
73+
"""
74+
Redirect project slugs that have underscores (``_``).
75+
76+
Slugs with underscores are no longer allowed.
77+
Underscores are replaced by ``-`` and then redirected to that URL.
78+
"""
7479
new_project_slug = invalid_project_slug.replace('_', '-')
7580
new_path = request.path.replace(invalid_project_slug, new_project_slug)
7681
return redirect('{}?{}'.format(

readthedocs/search/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def get_chunk(total, chunk_size):
104104

105105
def _get_index(indices, index_name):
106106
"""
107-
Get Index from all the indices
107+
Get Index from all the indices.
108108
109109
:param indices: DED indices list
110110
:param index_name: Name of the index
@@ -117,7 +117,7 @@ def _get_index(indices, index_name):
117117

118118
def _get_document(model, document_class):
119119
"""
120-
Get DED document class object from the model and name of document class
120+
Get DED document class object from the model and name of document class.
121121
122122
:param model: The model class to find the document
123123
:param document_class: the name of the document class.

readthedocs/search/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
def elastic_search(request, project_slug=None):
3838
"""
39-
Global user search on the dashboard
39+
Global user search on the dashboard.
4040
4141
This is for both the main search and project search.
4242

readthedocs/vcs_support/backends/bzr.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ def tags(self):
4949

5050
def parse_tags(self, data):
5151
"""
52-
Parses output of bzr tags, eg:
52+
Parses output of bzr tags.
53+
54+
Example:
5355
5456
0.1.0 171
5557
0.1.1 173

readthedocs/vcs_support/backends/hg.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ def branches(self):
5151

5252
def parse_branches(self, data):
5353
"""
54-
Parses output of `hg branches --quiet`, eg:
54+
Parses output of `hg branches --quiet`.
55+
56+
Example:
5557
5658
default
5759
0.2
@@ -73,7 +75,9 @@ def tags(self):
7375

7476
def parse_tags(self, data):
7577
"""
76-
Parses output of `hg tags`, eg:
78+
Parses output of `hg tags`.
79+
80+
Example:
7781
7882
tip 278:c4b2d21db51a
7983
0.2.2 152:6b0364d98837

readthedocs/vcs_support/backends/svn.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ def tags(self):
7878

7979
def parse_tags(self, data):
8080
"""
81-
Parses output of svn list, eg:
81+
Parses output of svn list.
82+
83+
Example:
8284
8385
release-1.1/
8486
release-1.2/

0 commit comments

Comments
 (0)