Skip to content
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

pre-commit command ran for humitos/log/sentry branch #3898

Closed
wants to merge 5 commits into from
Closed
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
1 change: 1 addition & 0 deletions .style.yapf
4 changes: 2 additions & 2 deletions docs/yaml-config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ This is the version of Python to use when building your documentation. If you
specify only the major version of Python, the highest supported minor version
will be selected.

.. warning::
.. warning::

The supported Python versions depends on the version of the build image your
project is using. The default build image that is used to build documentation
contains support for Python ``2.7`` and ``3.5``.
contains support for Python ``2.7`` and ``3.5``.
See the :ref:`yaml_build_image` for more information on supported Python versions.

.. code-block:: yaml
Expand Down
2 changes: 1 addition & 1 deletion readthedocs-common
134 changes: 104 additions & 30 deletions readthedocs/builds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import logging
import os.path
import re
from builtins import object
from shutil import rmtree

from builtins import object
from django.conf import settings
from django.core.urlresolvers import reverse
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
from guardian.shortcuts import assign
from taggit.managers import TaggableManager

Expand All @@ -35,7 +35,10 @@
from .version_slug import VersionSlugField

DEFAULT_VERSION_PRIVACY_LEVEL = getattr(
settings, 'DEFAULT_VERSION_PRIVACY_LEVEL', 'public')
settings,
'DEFAULT_VERSION_PRIVACY_LEVEL',
'public',
)

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -75,7 +78,10 @@ class Version(models.Model):
#: filesystem to determine how the paths for this version are called. It
#: must not be used for any other identifying purposes.
slug = VersionSlugField(
_('Slug'), max_length=255, populate_from='verbose_name')
_('Slug'),
max_length=255,
populate_from='verbose_name',
)

supported = models.BooleanField(_('Supported'), default=True)
active = models.BooleanField(_('Active'), default=False)
Expand All @@ -99,15 +105,17 @@ class Meta(object):
permissions = (
# Translators: Permission around whether a user can view the
# version
('view_version', _('View Version')),)
('view_version', _('View Version')),
)

def __str__(self):
return ugettext(
'Version {version} of {project} ({pk})'.format(
version=self.verbose_name,
project=self.project,
pk=self.pk,
))
),
)

@property
def commit_name(self):
Expand Down Expand Up @@ -148,7 +156,9 @@ def commit_name(self):

# If we came that far it's not a special version nor a branch or tag.
# Therefore just return the identifier to make a safe guess.
log.debug('TODO: Raise an exception here. Testing what cases it happens')
log.debug(
'TODO: Raise an exception here. Testing what cases it happens',
)
return self.identifier

def get_absolute_url(self):
Expand All @@ -162,7 +172,9 @@ def get_absolute_url(self):
)
private = self.privacy_level == PRIVATE
return self.project.get_docs_url(
version_slug=self.slug, private=private)
version_slug=self.slug,
private=private,
)

def save(self, *args, **kwargs): # pylint: disable=arguments-differ
"""Add permissions to the Version for all owners on save."""
Expand All @@ -175,15 +187,21 @@ def save(self, *args, **kwargs): # pylint: disable=arguments-differ
except Exception:
log.exception('failed to sync supported versions')
broadcast(
type='app', task=tasks.symlink_project, args=[self.project.pk])
type='app',
task=tasks.symlink_project,
args=[self.project.pk],
)
return obj

def delete(self, *args, **kwargs): # pylint: disable=arguments-differ
from readthedocs.projects import tasks
log.info('Removing files for version %s', self.slug)
broadcast(type='app', task=tasks.clear_artifacts, args=[self.pk])
broadcast(
type='app', task=tasks.symlink_project, args=[self.project.pk])
type='app',
task=tasks.symlink_project,
args=[self.project.pk],
)
super(Version, self).delete(*args, **kwargs)

@property
Expand All @@ -209,19 +227,27 @@ def get_downloads(self, pretty=False):
data['PDF'] = project.get_production_media_url('pdf', self.slug)
if project.has_htmlzip(self.slug):
data['HTML'] = project.get_production_media_url(
'htmlzip', self.slug)
'htmlzip',
self.slug,
)
if project.has_epub(self.slug):
data['Epub'] = project.get_production_media_url(
'epub', self.slug)
'epub',
self.slug,
)
else:
if project.has_pdf(self.slug):
data['pdf'] = project.get_production_media_url('pdf', self.slug)
if project.has_htmlzip(self.slug):
data['htmlzip'] = project.get_production_media_url(
'htmlzip', self.slug)
'htmlzip',
self.slug,
)
if project.has_epub(self.slug):
data['epub'] = project.get_production_media_url(
'epub', self.slug)
'epub',
self.slug,
)
return data

def get_conf_py_path(self):
Expand All @@ -247,13 +273,18 @@ def clean_build_path(self):
try:
path = self.get_build_path()
if path is not None:
log.debug('Removing build path {0} for {1}'.format(path, self))
log.debug('Removing build path %s for %s', path, self)
rmtree(path)
except OSError:
log.exception('Build path cleanup failed')

def get_github_url(
self, docroot, filename, source_suffix='.rst', action='view'):
self,
docroot,
filename,
source_suffix='.rst',
action='view',
Copy link
Member Author

Choose a reason for hiding this comment

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

Here, the function is affected by add-trailing-comma plugin.

I want to check how to disable this case.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is not a problem of this plugin, but a combination of add-trailing-comma plus yapf.

When this is detected

 def myfunc(
        a, b, c, d, e, f, argument, larger, here, to, reach, eighty, lines, NOW
 ):

trailing comma adds a comma in the end, and yapf format it on an argument per line in the next pass.

):
"""
Return a GitHub URL for a given filename.

Expand Down Expand Up @@ -295,7 +326,12 @@ def get_github_url(
)

def get_gitlab_url(
self, docroot, filename, source_suffix='.rst', action='view'):
self,
docroot,
filename,
source_suffix='.rst',
action='view',
):
repo_url = self.project.repo
if 'gitlab' not in repo_url:
return ''
Expand Down Expand Up @@ -391,10 +427,17 @@ class VersionAlias(models.Model):
"""Alias for a ``Version``."""

project = models.ForeignKey(
Project, verbose_name=_('Project'), related_name='aliases')
Project,
verbose_name=_('Project'),
related_name='aliases',
)
from_slug = models.CharField(_('From slug'), max_length=255, default='')
to_slug = models.CharField(
_('To slug'), max_length=255, default='', blank=True)
_('To slug'),
max_length=255,
default='',
blank=True,
)
largest = models.BooleanField(_('Largest'), default=False)

def __str__(self):
Expand All @@ -403,7 +446,8 @@ def __str__(self):
project=self.project,
_from=self.from_slug,
to=self.to_slug,
))
),
)


@python_2_unicode_compatible
Expand All @@ -412,13 +456,28 @@ class Build(models.Model):
"""Build data."""

project = models.ForeignKey(
Project, verbose_name=_('Project'), related_name='builds')
Project,
verbose_name=_('Project'),
related_name='builds',
)
version = models.ForeignKey(
Version, verbose_name=_('Version'), null=True, related_name='builds')
Version,
verbose_name=_('Version'),
null=True,
related_name='builds',
)
type = models.CharField(
_('Type'), max_length=55, choices=BUILD_TYPES, default='html')
_('Type'),
max_length=55,
choices=BUILD_TYPES,
default='html',
)
state = models.CharField(
_('State'), max_length=55, choices=BUILD_STATE, default='finished')
_('State'),
max_length=55,
choices=BUILD_STATE,
default='finished',
)
date = models.DateTimeField(_('Date'), auto_now_add=True)
success = models.BooleanField(_('Success'), default=True)

Expand All @@ -428,15 +487,25 @@ class Build(models.Model):
error = models.TextField(_('Error'), default='', blank=True)
exit_code = models.IntegerField(_('Exit code'), null=True, blank=True)
commit = models.CharField(
_('Commit'), max_length=255, null=True, blank=True)
_('Commit'),
max_length=255,
null=True,
blank=True,
)

length = models.IntegerField(_('Build Length'), null=True, blank=True)

builder = models.CharField(
_('Builder'), max_length=255, null=True, blank=True)
_('Builder'),
max_length=255,
null=True,
blank=True,
)

cold_storage = models.NullBooleanField(
_('Cold Storage'), help_text='Build steps stored outside the database.')
_('Cold Storage'),
help_text='Build steps stored outside the database.',
)

# Manager

Expand All @@ -455,7 +524,8 @@ def __str__(self):
self.project.users.all().values_list('username', flat=True),
),
pk=self.pk,
))
),
)

@models.permalink
def get_absolute_url(self):
Expand Down Expand Up @@ -497,7 +567,10 @@ class BuildCommandResult(BuildCommandResultMixin, models.Model):
"""Build command for a ``Build``."""

build = models.ForeignKey(
Build, verbose_name=_('Build'), related_name='commands')
Build,
verbose_name=_('Build'),
related_name='commands',
)

command = models.TextField(_('Command'))
description = models.TextField(_('Description'), blank=True)
Expand All @@ -516,7 +589,8 @@ class Meta(object):
def __str__(self):
return (
ugettext('Build command {pk} for build {build}')
.format(pk=self.pk, build=self.build))
.format(pk=self.pk, build=self.build)
)

@property
def run_time(self):
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/builds/static/builds/js/detail.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading