Skip to content

Docstring/PEP 257 fixes for the builds app #2831

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 10, 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 readthedocs/builds/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Django admin interface for `~builds.models.Build` and related models.

"""
"""Django admin interface for `~builds.models.Build` and related models."""

from django.contrib import admin
from readthedocs.builds.models import Build, VersionAlias, Version, BuildCommandResult
Expand Down
26 changes: 12 additions & 14 deletions readthedocs/builds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def commit_name(self):
The result could be used as ref in a git repo, e.g. for linking to
GitHub or Bitbucket.
"""

# LATEST is special as it is usually a branch but does not contain the
# name in verbose_name.
if self.slug == LATEST:
Expand Down Expand Up @@ -141,9 +140,7 @@ def get_absolute_url(self):
return self.project.get_docs_url(version_slug=self.slug, private=private)

def save(self, *args, **kwargs):
"""
Add permissions to the Version for all owners on save.
"""
"""Add permissions to the Version for all owners on save."""
from readthedocs.projects import tasks
obj = super(Version, self).save(*args, **kwargs)
for owner in self.project.users.all():
Expand All @@ -164,7 +161,7 @@ def delete(self, *args, **kwargs):

@property
def identifier_friendly(self):
'''Return display friendly identifier'''
"""Return display friendly identifier"""
if re.match(r'^[0-9a-f]{40}$', self.identifier, re.I):
return self.identifier[:8]
return self.identifier
Expand Down Expand Up @@ -201,18 +198,18 @@ def get_conf_py_path(self):
return conf_py_path

def get_build_path(self):
'''Return version build path if path exists, otherwise `None`'''
"""Return version build path if path exists, otherwise `None`"""
path = self.project.checkout_path(version=self.slug)
if os.path.exists(path):
return path
return None

def clean_build_path(self):
'''Clean build path for project version
"""Clean build path for project version

Ensure build path is clean for project version. Used to ensure stale
build checkouts for each project version are removed.
'''
"""
try:
path = self.get_build_path()
if path is not None:
Expand Down Expand Up @@ -349,28 +346,29 @@ def get_absolute_url(self):

@property
def finished(self):
'''Return if build has a finished state'''
"""Return if build has a finished state"""
return self.state == BUILD_STATE_FINISHED


class BuildCommandResultMixin(object):

'''Mixin for common command result methods/properties
"""Mixin for common command result methods/properties

Shared methods between the database model :py:class:`BuildCommandResult` and
non-model respresentations of build command results from the API
'''
"""

@property
def successful(self):
'''Did the command exit with a successful exit code'''
"""Did the command exit with a successful exit code"""
return self.exit_code == 0

@property
def failed(self):
'''Did the command exit with a failing exit code
"""Did the command exit with a failing exit code

Helper for inverse of :py:meth:`successful`'''
Helper for inverse of :py:meth:`successful`
"""
return not self.successful


Expand Down
5 changes: 2 additions & 3 deletions readthedocs/builds/version_slug.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@


class VersionSlugField(models.CharField):
"""
Implementation inspired by ``django_extensions.db.fields.AutoSlugField``.
"""

"""Inspired by ``django_extensions.db.fields.AutoSlugField``."""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pep257 plugin complains that the original should be pulled into a one-line docstring, but if you do, you exceed the 79-character line limit, so I tweaked the wording to fit.


invalid_chars_re = re.compile('[^-._a-z0-9]')
leading_punctuation_re = re.compile('^[-._]+')
Expand Down