Skip to content

Commit b7434c0

Browse files
authored
Merge pull request readthedocs#3408 from rtfd/humitos/tox/fix-lint
Pin pylint to 1.7.5 and fix docstring styling
2 parents 0da0243 + 5630fad commit b7434c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+509
-364
lines changed

prospector.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ pep257:
3535
- D105
3636
- D211
3737
- D104
38+
- D212 # Multi-line docstring summary should start at the first line
39+
- D107 # Missing docstring in __init__
40+
- D106 # Missing docstring in public nested class
41+
42+
# pydocstyle
43+
- D406 # Section name should end with a newline ('Examples', not 'Examples::')
44+
- D407 # Missing dashed underline after section ('Examples')
45+
- D412 # No blank lines allowed between a section header and its content ('Examples')
46+
- D413 # Missing blank line after last section ('Examples')
3847

3948
pyflakes:
4049
disable:

readthedocs/builds/managers.py

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

1717
class VersionManagerBase(models.Manager):
1818

19-
"""Version manager for manager only queries
19+
"""
20+
Version manager for manager only queries.
2021
2122
For queries not suitable for the :py:cls:`VersionQuerySet`, such as create
2223
queries.

readthedocs/builds/syncers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
"""Classes to copy files between build and web servers
1+
"""
2+
Classes to copy files between build and web servers.
23
3-
"Syncers" copy files from the local machine, while "Pullers" copy files to
4-
the local machine.
4+
"Syncers" copy files from the local machine, while "Pullers" copy files to the
5+
local machine.
56
"""
67

78
from __future__ import absolute_import

readthedocs/builds/version_slug.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""Contains logic for handling version slugs.
1+
"""
2+
Contains logic for handling version slugs.
23
34
Handling slugs for versions is not too straightforward. We need to allow some
45
characters which are uncommon in usual slugs. They are dots and underscores.
@@ -32,8 +33,8 @@ def get_fields_with_model(cls):
3233
"""
3334
Replace deprecated function of the same name in Model._meta.
3435
35-
This replaces deprecated function (as of Django 1.10) in
36-
Model._meta as prescrived in the Django docs.
36+
This replaces deprecated function (as of Django 1.10) in Model._meta as
37+
prescrived in the Django docs.
3738
https://docs.djangoproject.com/en/1.11/ref/models/meta/#migrating-from-the-old-api
3839
"""
3940
return [

readthedocs/core/admin.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Django admin interface for core models"""
1+
"""Django admin interface for core models."""
22

33
from __future__ import absolute_import
44
from datetime import datetime, timedelta
@@ -22,7 +22,7 @@ class UserProjectInline(admin.TabularInline):
2222

2323
class UserProjectFilter(admin.SimpleListFilter):
2424

25-
"""Filter users based on project properties"""
25+
"""Filter users based on project properties."""
2626

2727
parameter_name = 'project_state'
2828
title = _('user projects')
@@ -39,7 +39,8 @@ def lookups(self, request, model_admin):
3939
)
4040

4141
def queryset(self, request, queryset):
42-
"""Add filters to queryset filter
42+
"""
43+
Add filters to queryset filter.
4344
4445
``PROJECT_ACTIVE`` and ``PROJECT_BUILT`` look for versions on projects,
4546
``PROJECT_RECENT`` looks for projects with builds in the last year

readthedocs/core/middleware.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131

3232
class SubdomainMiddleware(object):
3333

34-
"""Middleware to display docs for non-dashboard domains"""
34+
"""Middleware to display docs for non-dashboard domains."""
3535

3636
def process_request(self, request):
37-
"""Process requests for unhandled domains
37+
"""
38+
Process requests for unhandled domains.
3839
3940
If the request is not for our ``PUBLIC_DOMAIN``, or if ``PUBLIC_DOMAIN``
4041
is not set and the request is for a subdomain on ``PRODUCTION_DOMAIN``,
@@ -132,22 +133,22 @@ def process_request(self, request):
132133

133134
class SingleVersionMiddleware(object):
134135

135-
"""Reset urlconf for requests for 'single_version' docs.
136-
137-
In settings.MIDDLEWARE_CLASSES, SingleVersionMiddleware must follow
138-
after SubdomainMiddleware.
136+
"""
137+
Reset urlconf for requests for 'single_version' docs.
139138
139+
In settings.MIDDLEWARE_CLASSES, SingleVersionMiddleware must follow after
140+
SubdomainMiddleware.
140141
"""
141142

142143
def _get_slug(self, request):
143-
"""Get slug from URLs requesting docs.
144+
"""
145+
Get slug from URLs requesting docs.
144146
145147
If URL is like '/docs/<project_name>/', we split path
146148
and pull out slug.
147149
148150
If URL is subdomain or CNAME, we simply read request.slug, which is
149151
set by SubdomainMiddleware.
150-
151152
"""
152153
slug = None
153154
if hasattr(request, 'slug'):
@@ -187,16 +188,16 @@ def process_request(self, request):
187188
class ProxyMiddleware(object):
188189

189190
"""
190-
Middleware that sets REMOTE_ADDR based on HTTP_X_FORWARDED_FOR, if the
191+
Middleware that sets REMOTE_ADDR based on HTTP_X_FORWARDED_FOR, if the.
191192
192193
latter is set. This is useful if you're sitting behind a reverse proxy that
193-
causes each request's REMOTE_ADDR to be set to 127.0.0.1.
194-
Note that this does NOT validate HTTP_X_FORWARDED_FOR. If you're not behind
195-
a reverse proxy that sets HTTP_X_FORWARDED_FOR automatically, do not use
196-
this middleware. Anybody can spoof the value of HTTP_X_FORWARDED_FOR, and
197-
because this sets REMOTE_ADDR based on HTTP_X_FORWARDED_FOR, that means
198-
anybody can "fake" their IP address. Only use this when you can absolutely
199-
trust the value of HTTP_X_FORWARDED_FOR.
194+
causes each request's REMOTE_ADDR to be set to 127.0.0.1. Note that this
195+
does NOT validate HTTP_X_FORWARDED_FOR. If you're not behind a reverse proxy
196+
that sets HTTP_X_FORWARDED_FOR automatically, do not use this middleware.
197+
Anybody can spoof the value of HTTP_X_FORWARDED_FOR, and because this sets
198+
REMOTE_ADDR based on HTTP_X_FORWARDED_FOR, that means anybody can "fake"
199+
their IP address. Only use this when you can absolutely trust the value of
200+
HTTP_X_FORWARDED_FOR.
200201
"""
201202

202203
def process_request(self, request):

readthedocs/core/resolver.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""URL resolver for documentation"""
1+
"""URL resolver for documentation."""
22

33
from __future__ import absolute_import
44
from builtins import object
@@ -54,7 +54,7 @@ class ResolverBase(object):
5454
def base_resolve_path(self, project_slug, filename, version_slug=None,
5555
language=None, private=False, single_version=None,
5656
subproject_slug=None, subdomain=None, cname=None):
57-
"""Resolve a with nothing smart, just filling in the blanks"""
57+
"""Resolve a with nothing smart, just filling in the blanks."""
5858
# Only support `/docs/project' URLs outside our normal environment. Normally
5959
# the path should always have a subdomain or CNAME domain
6060
# pylint: disable=unused-argument
@@ -80,7 +80,7 @@ def base_resolve_path(self, project_slug, filename, version_slug=None,
8080
def resolve_path(self, project, filename='', version_slug=None,
8181
language=None, single_version=None, subdomain=None,
8282
cname=None, private=None):
83-
"""Resolve a URL with a subset of fields defined"""
83+
"""Resolve a URL with a subset of fields defined."""
8484
relation = project.superprojects.first()
8585
cname = cname or project.domains.filter(canonical=True).first()
8686
main_language_project = project.main_language_project
@@ -145,7 +145,8 @@ def resolve(self, project, protocol='http', filename='', private=None,
145145
)
146146

147147
def _get_canonical_project(self, project):
148-
"""Get canonical project in the case of subproject or translations
148+
"""
149+
Get canonical project in the case of subproject or translations.
149150
150151
:type project: Project
151152
:rtype: Project
@@ -159,7 +160,7 @@ def _get_canonical_project(self, project):
159160
return project
160161

161162
def _get_project_subdomain(self, project):
162-
"""Determine canonical project domain as subdomain"""
163+
"""Determine canonical project domain as subdomain."""
163164
public_domain = getattr(settings, 'PUBLIC_DOMAIN', None)
164165
if self._use_subdomain():
165166
project = self._get_canonical_project(project)
@@ -177,9 +178,10 @@ def _get_private(self, project, version_slug):
177178

178179
def _fix_filename(self, project, filename):
179180
"""
180-
Force filenames that might be HTML file paths into proper URL's
181+
Force filenames that might be HTML file paths into proper URL's.
181182
182-
This basically means stripping / and .html endings and then re-adding them properly.
183+
This basically means stripping / and .html endings and then re-adding
184+
them properly.
183185
"""
184186
# Bail out on non-html files
185187
if '.' in filename and '.html' not in filename:
@@ -203,7 +205,7 @@ def _fix_filename(self, project, filename):
203205
return path
204206

205207
def _use_subdomain(self):
206-
"""Make decision about whether to use a subdomain to serve docs"""
208+
"""Make decision about whether to use a subdomain to serve docs."""
207209
use_subdomain = getattr(settings, 'USE_SUBDOMAIN', False)
208210
public_domain = getattr(settings, 'PUBLIC_DOMAIN', None)
209211
return use_subdomain and public_domain is not None

readthedocs/core/settings.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Class based settings for complex settings inheritance"""
1+
"""Class based settings for complex settings inheritance."""
22

33
from __future__ import absolute_import
44
from builtins import object
@@ -8,11 +8,12 @@
88

99
class Settings(object):
1010

11-
"""Class-based settings wrapper"""
11+
"""Class-based settings wrapper."""
1212

1313
@classmethod
1414
def load_settings(cls, module_name):
15-
"""Export class variables and properties to module namespace
15+
"""
16+
Export class variables and properties to module namespace.
1617
1718
This will export and class variable that is all upper case and doesn't
1819
begin with ``_``. These members will be set as attributes on the module

readthedocs/core/symlink.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
ja/
5151
5252
fabric -> rtd-builds/fabric/en/latest/ # single version
53-
5453
"""
5554

5655
from __future__ import absolute_import
@@ -121,9 +120,8 @@ def run(self):
121120
"""
122121
Create proper symlinks in the right order.
123122
124-
Since we have a small nest of directories and symlinks,
125-
the ordering of these calls matter,
126-
so we provide this helper to make life easier.
123+
Since we have a small nest of directories and symlinks, the ordering of
124+
these calls matter, so we provide this helper to make life easier.
127125
"""
128126
# Outside of the web root
129127
self.symlink_cnames()
@@ -138,7 +136,8 @@ def run(self):
138136
self.symlink_versions()
139137

140138
def symlink_cnames(self, domain=None):
141-
"""Symlink project CNAME domains
139+
"""
140+
Symlink project CNAME domains.
142141
143142
Link from HOME/$CNAME_ROOT/<cname> ->
144143
HOME/$WEB_ROOT/<project>
@@ -164,13 +163,14 @@ def symlink_cnames(self, domain=None):
164163
run(['ln', '-nsf', self.project.doc_path, project_cname_symlink])
165164

166165
def remove_symlink_cname(self, domain):
167-
"""Remove CNAME symlink"""
166+
"""Remove CNAME symlink."""
168167
self._log(u"Removing symlink for CNAME {0}".format(domain.domain))
169168
symlink = os.path.join(self.CNAME_ROOT, domain.domain)
170169
os.unlink(symlink)
171170

172171
def symlink_subprojects(self):
173-
"""Symlink project subprojects
172+
"""
173+
Symlink project subprojects.
174174
175175
Link from $WEB_ROOT/projects/<project> ->
176176
$WEB_ROOT/<project>
@@ -213,7 +213,8 @@ def symlink_subprojects(self):
213213
os.unlink(os.path.join(self.subproject_root, subproj))
214214

215215
def symlink_translations(self):
216-
"""Symlink project translations
216+
"""
217+
Symlink project translations.
217218
218219
Link from $WEB_ROOT/<project>/<language>/ ->
219220
$WEB_ROOT/<translation>/<language>/
@@ -247,7 +248,8 @@ def symlink_translations(self):
247248
shutil.rmtree(to_delete)
248249

249250
def symlink_single_version(self):
250-
"""Symlink project single version
251+
"""
252+
Symlink project single version.
251253
252254
Link from $WEB_ROOT/<project> ->
253255
HOME/user_builds/<project>/rtd-builds/latest/
@@ -268,7 +270,8 @@ def symlink_single_version(self):
268270
run(['ln', '-nsf', docs_dir, symlink])
269271

270272
def symlink_versions(self):
271-
"""Symlink project's versions
273+
"""
274+
Symlink project's versions.
272275
273276
Link from $WEB_ROOT/<project>/<language>/<version>/ ->
274277
HOME/user_builds/<project>/rtd-builds/<version>
@@ -295,7 +298,7 @@ def symlink_versions(self):
295298
os.unlink(os.path.join(version_dir, old_ver))
296299

297300
def get_default_version(self):
298-
"""Look up project default version, return None if not found"""
301+
"""Look up project default version, return None if not found."""
299302
default_version = self.project.get_default_version()
300303
try:
301304
return self.get_version_queryset().get(slug=default_version)

readthedocs/core/tasks.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Basic tasks"""
1+
"""Basic tasks."""
22

33
from __future__ import absolute_import
44
import logging
@@ -19,7 +19,8 @@
1919
@app.task(queue='web', time_limit=EMAIL_TIME_LIMIT)
2020
def send_email_task(recipient, subject, template, template_html,
2121
context=None, from_email=None, **kwargs):
22-
"""Send multipart email
22+
"""
23+
Send multipart email.
2324
2425
recipient
2526
Email recipient address

readthedocs/core/utils/__init__.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Common utilty functions"""
1+
"""Common utilty functions."""
22

33
from __future__ import absolute_import
44

@@ -77,7 +77,8 @@ def cname_to_slug(host):
7777

7878

7979
def trigger_build(project, version=None, record=True, force=False, basic=False):
80-
"""Trigger build for project and version
80+
"""
81+
Trigger build for project and version.
8182
8283
If project has a ``build_queue``, execute task on this build queue. Queue
8384
will be prefixed with ``build-`` to unify build queue names.
@@ -135,7 +136,8 @@ def trigger_build(project, version=None, record=True, force=False, basic=False):
135136

136137
def send_email(recipient, subject, template, template_html, context=None,
137138
request=None, from_email=None, **kwargs): # pylint: disable=unused-argument
138-
"""Alter context passed in and call email send task
139+
"""
140+
Alter context passed in and call email send task.
139141
140142
.. seealso::
141143
@@ -152,7 +154,8 @@ def send_email(recipient, subject, template, template_html, context=None,
152154

153155

154156
def slugify(value, *args, **kwargs):
155-
"""Add a DNS safe option to slugify
157+
"""
158+
Add a DNS safe option to slugify.
156159
157160
:param dns_safe: Remove underscores from slug as well
158161
"""
@@ -170,9 +173,9 @@ def safe_makedirs(directory_name):
170173
"""
171174
Safely create a directory.
172175
173-
Makedirs has an issue where it has a race condition around
174-
checking for a directory and then creating it.
175-
This catches the exception in the case where the dir already exists.
176+
Makedirs has an issue where it has a race condition around checking for a
177+
directory and then creating it. This catches the exception in the case where
178+
the dir already exists.
176179
"""
177180
try:
178181
os.makedirs(directory_name)

0 commit comments

Comments
 (0)