Skip to content

CI: fix linter #7261

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 2 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
47 changes: 0 additions & 47 deletions prospector-more.yml

This file was deleted.

1 change: 1 addition & 0 deletions prospector-more.yml
8 changes: 4 additions & 4 deletions readthedocs/analytics/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def top_viewed_pages(cls, project, since=None):
if since is None:
since = timezone.now().date() - timezone.timedelta(days=30)

qs = (
queryset = (
cls.objects
.filter(project=project, date__gte=since)
.values_list('path')
Expand All @@ -74,7 +74,7 @@ def top_viewed_pages(cls, project, since=None):
pages = []
view_counts = []

for data in qs.iterator():
for data in queryset.iterator():
pages.append(data[0])
view_counts.append(data[1])

Expand Down Expand Up @@ -102,13 +102,13 @@ def page_views_by_date(cls, project_slug, since=None):
if since is None:
since = timezone.now().date() - timezone.timedelta(days=30)

qs = cls.objects.filter(
queryset = cls.objects.filter(
project__slug=project_slug,
date__gt=since,
).values('date').annotate(total_views=Sum('view_count')).order_by('date')

count_dict = dict(
qs.order_by('date').values_list('date', 'total_views')
queryset.order_by('date').values_list('date', 'total_views')
)

# This fills in any dates where there is no data
Expand Down
32 changes: 16 additions & 16 deletions readthedocs/api/v2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,22 @@ def sync_versions_to_db(project, versions, type): # pylint: disable=redefined-b
if version_id == old_versions[version_name]:
# Version is correct
continue
else:
# Update slug with new identifier
Version.objects.filter(
project=project,
verbose_name=version_name,
).update(
identifier=version_id,
type=type,
machine=False,
) # noqa

log.info(
'(Sync Versions) Updated Version: [%s=%s] ',
version_name,
version_id,
)

# Update slug with new identifier
Version.objects.filter(
project=project,
verbose_name=version_name,
).update(
identifier=version_id,
type=type,
machine=False,
) # noqa

log.info(
'(Sync Versions) Updated Version: [%s=%s] ',
version_name,
version_id,
)
else:
# New Version
created_version = Version.objects.create(
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/api/v2/views/integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def get_response_push(self, project, branches):
project,
branches,
)
triggered = True if to_build else False
triggered = bool(to_build)
return {
'build_triggered': triggered,
'project': project.slug,
Expand Down
1 change: 1 addition & 0 deletions readthedocs/api/v3/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# allows /api/v3/projects/
# allows /api/v3/projects/pip/
# allows /api/v3/projects/pip/superproject/
# pylint: disable=assignment-from-no-return
projects = router.register(
r'projects',
ProjectsViewSet,
Expand Down
4 changes: 2 additions & 2 deletions readthedocs/builds/version_slug.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def __init__(self, *args, **kwargs):
populate_from = kwargs.pop('populate_from', None)
if populate_from is None:
raise ValueError("missing 'populate_from' argument")
else:
self._populate_from = populate_from

self._populate_from = populate_from
Copy link
Member

@ericholscher ericholscher Jul 7, 2020

Choose a reason for hiding this comment

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

I really don't like this linter setting -- I find the else statement much more explicit :(

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm fine with both styles. We can disable that check if we want

super().__init__(*args, **kwargs)

def get_queryset(self, model_cls, slug_field):
Expand Down
6 changes: 2 additions & 4 deletions readthedocs/core/models.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# -*- coding: utf-8 -*-

"""Models for the core app."""
import logging

from annoying.fields import AutoOneToOneField
from django.contrib.auth.models import User
from django.db import models
from django.urls import reverse
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _


log = logging.getLogger(__name__)


Expand All @@ -18,7 +16,7 @@ class UserProfile(models.Model):
"""Additional information about a User."""

user = AutoOneToOneField(
'auth.User',
User,
verbose_name=_('User'),
related_name='profile',
on_delete=models.CASCADE,
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/core/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def _use_custom_domain(self, custom_domain):
:param custom_domain: Domain instance or ``None``
:type custom_domain: readthedocs.projects.models.Domain
"""
return True if custom_domain is not None else False
return custom_domain is not None

def _use_subdomain(self):
"""Make decision about whether to use a subdomain to serve docs."""
Expand Down
30 changes: 15 additions & 15 deletions readthedocs/doc_builder/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,21 +838,21 @@ def __enter__(self):
if self.build:
self.build['state'] = BUILD_STATE_FINISHED
raise exc
else:
log.warning(
LOG_TEMPLATE,
{
'project': self.project.slug,
'version': self.version.slug,
'msg': (
'Removing stale container {}'.format(
self.container_id,
)
),
}
)
client = self.get_client()
client.remove_container(self.container_id)

log.warning(
LOG_TEMPLATE,
{
'project': self.project.slug,
'version': self.version.slug,
'msg': (
'Removing stale container {}'.format(
self.container_id,
)
),
}
)
client = self.get_client()
client.remove_container(self.container_id)
except (DockerAPIError, ConnectionError):
# If there is an exception here, we swallow the exception as this
# was just during a sanity check anyways.
Expand Down
5 changes: 2 additions & 3 deletions readthedocs/gold/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,9 @@ def clean_project(self):

if not project_instance.exists():
raise forms.ValidationError(_('No project found.'))
elif project_instance.first() in self.projects:
if project_instance.first() in self.projects:
raise forms.ValidationError(_('This project is already Ad-Free.'))
else:
return project_slug
return project_slug

def clean(self):
cleaned_data = super().clean()
Expand Down
6 changes: 3 additions & 3 deletions readthedocs/gold/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import math
from datetime import datetime

import pytz
from django.contrib.auth.models import User
from django.db import models
from django.utils.translation import ugettext_lazy as _
import pytz

from readthedocs.projects.models import Project


#: The membership options that are currently available
LEVEL_CHOICES = (
('v1-org-5', '$5/mo'),
Expand All @@ -31,7 +31,7 @@ class GoldUser(models.Model):
modified_date = models.DateTimeField(_('Modified date'), auto_now=True)

user = models.ForeignKey(
'auth.User',
User,
verbose_name=_('User'),
unique=True,
related_name='gold',
Expand Down
10 changes: 5 additions & 5 deletions readthedocs/oauth/services/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ def create_repository(self, fields, privacy=None, organization=None):
repo.json = json.dumps(fields)
repo.save()
return repo
else:
log.debug(
'Not importing %s because mismatched type',
fields['name'],
)

log.debug(
'Not importing %s because mismatched type',
fields['name'],
)

def create_organization(self, fields):
"""
Expand Down
12 changes: 6 additions & 6 deletions readthedocs/oauth/services/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ def create_repository(self, fields, privacy=None, organization=None):
repo.json = json.dumps(fields)
repo.save()
return repo
else:
log.info(
'Not importing %s because mismatched type: visibility=%s',
fields['name_with_namespace'],
fields['visibility'],
)

log.info(
'Not importing %s because mismatched type: visibility=%s',
fields['name_with_namespace'],
fields['visibility'],
)

def create_organization(self, fields):
"""
Expand Down
8 changes: 4 additions & 4 deletions readthedocs/organizations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from django.utils.crypto import salted_hmac
from django.utils.translation import ugettext_lazy as _

from readthedocs.core.utils import slugify
from readthedocs.core.permissions import AdminPermission
from readthedocs.core.utils import slugify

from . import constants
from .managers import TeamManager, TeamMemberManager
Expand Down Expand Up @@ -99,7 +99,7 @@ def users(self):
def members(self):
return AdminPermission.members(self)

def save(self, *args, **kwargs): # pylint: disable=arguments-differ
def save(self, *args, **kwargs): # pylint: disable=signature-differs
if not self.slug:
self.slug = slugify(self.name)

Expand Down Expand Up @@ -204,7 +204,7 @@ def __str__(self):
team=self.name,
)

def save(self, *args, **kwargs): # pylint: disable=arguments-differ
def save(self, *args, **kwargs): # pylint: disable=signature-differs
if not self.slug:
self.slug = slugify(self.name)
super().save(*args, **kwargs)
Expand Down Expand Up @@ -245,7 +245,7 @@ def __str__(self):
team=self.team,
)

def save(self, *args, **kwargs): # pylint: disable=arguments-differ
def save(self, *args, **kwargs): # pylint: disable=signature-differs
hash_ = salted_hmac(
# HMAC key per applications
'.'.join([self.__module__, self.__class__.__name__]),
Expand Down
8 changes: 4 additions & 4 deletions readthedocs/projects/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,21 +742,21 @@ def clean_name(self):
raise forms.ValidationError(
_("Variable name can't start with __ (double underscore)"),
)
elif name.startswith('READTHEDOCS'):
if name.startswith('READTHEDOCS'):
raise forms.ValidationError(
_("Variable name can't start with READTHEDOCS"),
)
elif self.project.environmentvariable_set.filter(name=name).exists():
if self.project.environmentvariable_set.filter(name=name).exists():
raise forms.ValidationError(
_(
'There is already a variable with this name for this project',
),
)
elif ' ' in name:
if ' ' in name:
raise forms.ValidationError(
_("Variable name can't contain spaces"),
)
elif not fullmatch('[a-zA-Z0-9_]+', name):
if not fullmatch('[a-zA-Z0-9_]+', name):
raise forms.ValidationError(
_('Only letters, numbers and underscore are allowed'),
)
Expand Down
6 changes: 3 additions & 3 deletions readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ class ProjectRelationship(models.Model):
"""

parent = models.ForeignKey(
'Project',
'projects.Project',
verbose_name=_('Parent'),
related_name='subprojects',
on_delete=models.CASCADE,
)
child = models.ForeignKey(
'Project',
'projects.Project',
verbose_name=_('Child'),
related_name='superprojects',
on_delete=models.CASCADE,
Expand Down Expand Up @@ -1330,7 +1330,7 @@ class ImportedFile(models.Model):
"""

project = models.ForeignKey(
'Project',
Project,
verbose_name=_('Project'),
related_name='imported_files',
on_delete=models.CASCADE,
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/projects/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,7 @@ def warn(self, msg):
'Error while getting sphinx domain information for %s:%s:%s. Skipping.',
version.project.slug,
version.slug,
f'domain->name',
f'{domain}->{name}',
)
continue

Expand Down
Loading