Skip to content

Assorted docstring/PEP 257 fixes #2835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions deploy/flask-redirects.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
A flask app for redirecting documentation from the root / URL.
"""
"""A Flask app for redirecting documentation from the root / URL."""

import json

Expand Down
3 changes: 1 addition & 2 deletions readthedocs/bookmarks/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Django admin interface for `~bookmarks.models.Bookmark`.
"""
"""Django admin interface for `~bookmarks.models.Bookmark`."""

from django.contrib import admin
from readthedocs.bookmarks.models import Bookmark
Expand Down
1 change: 1 addition & 0 deletions readthedocs/bookmarks/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def post(self, request, *args, **kwargs):
class BookmarkRemoveView(View):
"""
Deletes a user's bookmark in response to a POST request.

Renders a delete? confirmation page in response to a GET request.
"""

Expand Down
1 change: 0 additions & 1 deletion readthedocs/oauth/services/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def token_updater(self, token):
u'expires_at': 1449218652.558185
}
"""

def _updater(data):
token.token = data['access_token']
token.expires_at = datetime.fromtimestamp(data['expires_at'])
Expand Down
18 changes: 7 additions & 11 deletions readthedocs/privacy/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@

class ProjectManager(models.Manager):

"""
Projects take into account their own privacy_level setting.
"""
"""Projects take into account their own privacy_level setting."""

use_for_related_fields = True

Expand All @@ -30,9 +28,7 @@ def _add_user_repos(self, queryset, user):
return queryset.distinct()

def for_user_and_viewer(self, user, viewer):
"""
Show projects that a user owns, that another user can see.
"""
"""Show projects that a user owns, that another user can see."""
queryset = self.filter(privacy_level=constants.PUBLIC)
queryset = self._add_user_repos(queryset, viewer)
queryset = queryset.filter(users__in=[user])
Expand Down Expand Up @@ -120,9 +116,7 @@ def create_latest(self, **kwargs):

class VersionQuerySetBase(models.QuerySet):

"""
Versions take into account their own privacy_level setting.
"""
"""Versions take into account their own privacy_level setting."""

use_for_related_fields = True

Expand Down Expand Up @@ -183,7 +177,8 @@ class VersionQuerySet(SettingsOverrideObject):
class BuildManager(models.Manager):

"""
Build objects take into account the privacy of the Version they relate to.
Build objects that take into account the privacy of the Version
that they relate to.
"""

use_for_related_fields = True
Expand Down Expand Up @@ -216,6 +211,7 @@ class RelatedProjectManager(models.Manager):

This shouldn't be used as a subclass.
"""

use_for_related_fields = True
project_field = 'project'

Expand Down Expand Up @@ -278,7 +274,7 @@ class ChildRelatedProjectManager(RelatedProjectManager):

class RelatedBuildManager(models.Manager):

'''For models with association to a project through :py:class:`Build`'''
"""For models with association to a project through :py:class:`Build`"""

use_for_related_fields = True

Expand Down
7 changes: 4 additions & 3 deletions readthedocs/redirects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ def __unicode__(self):

def get_full_path(self, filename, language=None, version_slug=None):
"""
Return a full path for a given filename. This will include version and
language information. No protocol/domain is returned.
"""
Return a full path for a given filename.

This will include version and language information. No protocol/domain
is returned.
"""
# Handle explicit http redirects
if re.match('^https?://', filename):
return filename
Expand Down
4 changes: 3 additions & 1 deletion readthedocs/rtd_tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def tearDown(self):
@patch('readthedocs.projects.views.private.trigger_build', lambda x, basic: None)
@patch('readthedocs.projects.views.private.trigger_build', lambda x, basic: None)
class MockBuildTestCase(TestCase):
'''Mock build triggers for test cases'''

"""Mock build triggers for test cases"""

pass


Expand Down
7 changes: 4 additions & 3 deletions readthedocs/rtd_tests/mocks/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@


class EnvironmentMockGroup(object):
'''Mock out necessary environment pieces'''

"""Mock out necessary environment pieces"""

def __init__(self):
self.patches = {
Expand Down Expand Up @@ -43,7 +44,7 @@ def __init__(self):
self.mocks = {}

def start(self):
'''Create a patch object for class patches'''
"""Create a patch object for class patches"""
for patch in self.patches:
self.mocks[patch] = self.patches[patch].start()
self.mocks['process'].communicate.return_value = ('', '')
Expand All @@ -61,7 +62,7 @@ def stop(self):
pass

def configure_mock(self, mock, kwargs):
'''Configure object mocks'''
"""Configure object mocks"""
self.mocks[mock].configure_mock(**kwargs)

def __getattr__(self, name):
Expand Down
9 changes: 7 additions & 2 deletions readthedocs/rtd_tests/mocks/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

def fake_paths(check):
"""
Usage:

>>> with fake_paths(lambda path: True if path.endswith('.pdf') else None):
... assert os.path.exists('my.pdf')
... assert os.path.exists('Nopdf.txt')

The first assertion will be ok, the second assertion is not faked as the
``check`` returned ``None`` for this path.
"""

original_exists = os.path.exists

def patched_exists(path):
Expand All @@ -26,6 +27,8 @@ def patched_exists(path):

def fake_paths_lookup(path_dict):
"""
Usage:

>>> paths = {'my.txt': True, 'no.txt': False}
>>> with fake_paths_lookup(paths):
... assert os.path.exists('my.txt') == True
Expand All @@ -37,7 +40,9 @@ def check(path):


def fake_paths_by_regex(pattern, exists=True):
"""
r"""
Usage:

>>> with fake_paths_by_regex('\.pdf$'):
... assert os.path.exists('my.pdf') == True
>>> with fake_paths_by_regex('\.pdf$', exists=False):
Expand Down
1 change: 0 additions & 1 deletion readthedocs/search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

def elastic_search(request):
"""Use Elasticsearch for global search"""

query = request.GET.get('q')
type = request.GET.get('type', 'project')
# File Facets
Expand Down
2 changes: 2 additions & 0 deletions readthedocs/vcs_support/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def __exit__(self, exc, value, tb):
class NonBlockingLock(object):

"""
Acquire a lock in a non-blocking manner.

Instead of waiting for a lock, depending on the lock file age, either
acquire it immediately or throw LockTimeout

Expand Down