Skip to content

Commit

Permalink
Merge pull request #447 from kat-git-hub/remove-noqa-comments
Browse files Browse the repository at this point in the history
Remove # noqa: WPS comment
  • Loading branch information
sgmdlt authored Aug 7, 2024
2 parents e89f71a + 6137ebe commit 0d632a9
Show file tree
Hide file tree
Showing 38 changed files with 203 additions and 713 deletions.
2 changes: 1 addition & 1 deletion auth/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ class Meta(forms.UserChangeForm.Meta):
class UserTokenForm(django_forms.ModelForm):
"""User GitHub token change form."""

class Meta: # noqa: WPS306
class Meta:
model = SiteUser
fields = ['github_token']
2 changes: 1 addition & 1 deletion config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

def trigger_error(request):
"""Trigger error for Sentry checking."""
division_by_zero = 1 / 0 # noqa: F841, WPS344
division_by_zero = 1 / 0 # noqa: F841


urlpatterns = [
Expand Down
4 changes: 2 additions & 2 deletions contributors/admin/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ class ModelAdmin(admin.ModelAdmin):

def change_tracking(self, request, queryset):
"""Inverse tracking of the object."""
for obj in queryset: # noqa: WPS110
for obj in queryset:
obj.is_tracked = not obj.is_tracked
if not obj.is_tracked:
obj.is_visible = False
obj.save()

def change_visibility(self, request, queryset):
"""Inverse visibility of the object."""
for obj in queryset: # noqa: WPS110
for obj in queryset:
obj.is_visible = not obj.is_visible
if obj.is_visible:
obj.is_tracked = True
Expand Down
8 changes: 4 additions & 4 deletions contributors/management/commands/fetchdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
session = requests.Session()


def create_contributions( # noqa: C901,WPS231,WPS210
def create_contributions( # noqa: C901
repo, contrib_data, user_field=None, id_field=None, type_=None,
):
"""Create a contribution record."""
Expand Down Expand Up @@ -109,7 +109,7 @@ def create_contributions( # noqa: C901,WPS231,WPS210
class Command(management.base.BaseCommand):
"""A management command for syncing with GitHub."""

help = "Saves data from GitHub to database" # noqa: WPS125
help = "Saves data from GitHub to database"

def add_arguments(self, parser):
"""Add arguments for the command."""
Expand All @@ -123,7 +123,7 @@ def add_arguments(self, parser):
'--repo', nargs='*', help='a list of repository full names',
)

def handle( # noqa: C901,WPS110,WPS213,WPS231,WPS210
def handle( # noqa: C901
self, *args, **options,
):
"""Collect data from GitHub."""
Expand Down Expand Up @@ -158,7 +158,7 @@ def handle( # noqa: C901,WPS110,WPS213,WPS231,WPS210
if repo['name'] not in IGNORED_REPOSITORIES
]
number_of_repos = len(repos_to_process)
for i, repo_data in enumerate(repos_to_process, start=1): # noqa: WPS111,E501
for i, repo_data in enumerate(repos_to_process, start=1): # noqa: E501
repo, _ = misc.update_or_create_record(Repository, repo_data)
logger.info(f"{repo} ({i}/{number_of_repos})")
if repo_data['size'] == 0:
Expand Down
2 changes: 1 addition & 1 deletion contributors/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CommonFields(models.Model):
html_url = models.URLField(_("URL"))
is_tracked = models.BooleanField(_("tracked"), default=True)

objects = CTEManager() # noqa: WPS110
objects = CTEManager()

class Meta(object):
abstract = True
Expand Down
14 changes: 7 additions & 7 deletions contributors/models/contribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def for_year(self):
"""Return yearly results."""
datetime_now = timezone.now()
date_eleven_months_ago = (datetime_now - relativedelta.relativedelta(
months=11, day=1, # noqa: WPS432
months=11, day=1,
)).date()

months_with_contrib_sums = self.get_queryset().filter(
Expand Down Expand Up @@ -68,10 +68,10 @@ def visible_for_week(self):
class Contribution(models.Model):
"""Model representing a set of contributions."""

ID_LENGTH = 40 # noqa: WPS115
TYPE_LENGTH = 3 # noqa: WPS115
ID_LENGTH = 40
TYPE_LENGTH = 3

TYPES = ( # noqa: WPS115
TYPES = (
('cit', _("commit")),
('iss', _("issue")),
('pr', _("pull request")),
Expand All @@ -88,12 +88,12 @@ class Contribution(models.Model):
on_delete=models.CASCADE,
verbose_name=_("contributor"),
)
id = models.CharField(primary_key=True, max_length=ID_LENGTH) # noqa: A003,WPS125,E501
type = models.CharField(_("type"), choices=TYPES, max_length=TYPE_LENGTH) # noqa: A003,WPS125,E501
id = models.CharField(primary_key=True, max_length=ID_LENGTH) # noqa: A003,E501
type = models.CharField(_("type"), choices=TYPES, max_length=TYPE_LENGTH) # noqa: A003,E501
html_url = models.URLField(_("URL"))
created_at = models.DateTimeField(_("creation date"))

objects = ContributionManager() # noqa: WPS110
objects = ContributionManager()

labels = models.ManyToManyField(
ContributionLabel,
Expand Down
2 changes: 1 addition & 1 deletion contributors/models/contribution_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class ContributionLabel(models.Model):
"""Model representing a label."""

NAME_LENGTH = 45 # noqa: WPS115
NAME_LENGTH = 45

name = models.CharField(max_length=NAME_LENGTH)

Expand Down
2 changes: 1 addition & 1 deletion contributors/models/contributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Contributor(CommonFields):
avatar_url = models.URLField(_("avatar URL"))
is_visible = models.BooleanField(_("visible"), default=True)

objects = ContributorQuerySet.as_manager() # noqa: WPS110
objects = ContributorQuerySet.as_manager()

class Meta(object):
verbose_name = _("contributor")
Expand Down
4 changes: 2 additions & 2 deletions contributors/models/issue_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
class IssueInfo(models.Model):
"""Additional info for an issue or pull request."""

TITLE_LENGTH = 255 # noqa: WPS115
STATE_LENGTH = 10 # noqa: WPS115
TITLE_LENGTH = 255
STATE_LENGTH = 10

issue = models.OneToOneField(
'Contribution',
Expand Down
2 changes: 1 addition & 1 deletion contributors/models/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class Label(models.Model):
"""Model representing a label."""

NAME_LENGTH = 60 # noqa: WPS115
NAME_LENGTH = 60

name = models.CharField(max_length=NAME_LENGTH)

Expand Down
2 changes: 1 addition & 1 deletion contributors/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class Repository(CommonFields):
"""Model representing a repository."""

FULL_NAME_LENGTH = 100 # noqa: WPS115
FULL_NAME_LENGTH = 100

contributors = models.ManyToManyField(
Contributor,
Expand Down
6 changes: 3 additions & 3 deletions contributors/templatetags/contrib_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_query_string(context, qs_param, qs_param_value):
@register.simple_tag(takes_context=True)
def get_sort_query_string(context, passed_sort_field):
"""Get table column query string."""
def prepare_sort_param_value(ordering): # noqa: WPS430
def prepare_sort_param_value(ordering):
ordering = ordering or context['view'].get_ordering()
current_sort_field = split_ordering(ordering)[1]
if passed_sort_field == current_sort_field:
Expand All @@ -72,7 +72,7 @@ def get_pagination_query_string(context, page_num):
@register.simple_tag(takes_context=True)
def get_label_query_string(context, passed_label):
"""Get labels query string."""
def prepare_labels_param_value(labels_param): # noqa: WPS430
def prepare_labels_param_value(labels_param):
delimiter = '.'
labels = labels_param.split(delimiter) if labels_param else []
if passed_label in labels:
Expand All @@ -87,7 +87,7 @@ def prepare_labels_param_value(labels_param): # noqa: WPS430
@register.simple_tag(takes_context=True)
def get_contribution_label_query_string(context, passed_label):
"""Get labels query string."""
def prepare_contribution_labels_param_value(labels_param): # noqa: WPS430
def prepare_contribution_labels_param_value(labels_param):
delimiter = '.'
labels = labels_param.split(delimiter) if labels_param else []
if passed_label in labels:
Expand Down
2 changes: 1 addition & 1 deletion contributors/tests/test_contributors_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ def test_contributions_label_methods(self):
class CommonFieldTestClass(CommonFields):
"""Empty class to test an abstract class."""

pass # noqa: WPS420, WPS604
pass
4 changes: 2 additions & 2 deletions contributors/tests/test_leaderboard_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from django.urls import reverse

SEARCH_FORM_CONTEXT_NAME = "form_org"
SEARCH_PARAM_ORG_EXISTS = { # noqa: WPS407
SEARCH_PARAM_ORG_EXISTS = {
"search": "",
"organizations": "Hexlet",
}
SEARCH_PARAM_ORG_NOT_EXISTS = { # noqa: WPS407
SEARCH_PARAM_ORG_NOT_EXISTS = {
"search": "",
"organizations": "123456",
}
Expand Down
2 changes: 1 addition & 1 deletion contributors/utils/github_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def get_commit_stats_for_contributor(repo_full_name, contributor_id):
return totals['c'], totals['a'], totals['d']


def get_data_of_owners_and_repos(*, owner_names=None, repo_full_names=None): # noqa: C901,R701,E501,WPS231
def get_data_of_owners_and_repos(*, owner_names=None, repo_full_names=None): # noqa: C901,R701,E501
"""Return data of owners and their repositories from GitHub."""
if not (owner_names or repo_full_names):
raise ValueError("Neither owner_names nor repo_full_names is provided")
Expand Down
6 changes: 3 additions & 3 deletions contributors/utils/github_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def signatures_match(payload_body, gh_signature):
return hmac.compare_digest(signature, gh_signature)


def update_database(event_type, payload): # noqa: WPS210, C901
def update_database(event_type, payload): # noqa: C901
"""Update the database with an event's data."""
action = payload.get('action', 'created')
if action not in {'created', 'opened', 'edited', 'closed', 'reopened'}:
Expand Down Expand Up @@ -98,9 +98,9 @@ def update_database(event_type, payload): # noqa: WPS210, C901
payload['commits'][0]['timestamp'],
),
timezone.utc,
).strftime('%Y-%m-%dT%H:%M:%SZ') # noqa: WPS323
).strftime('%Y-%m-%dT%H:%M:%SZ')
if event_type == 'push':
for gh_commit in github.get_repo_commits_except_merges( # noqa: WPS352
for gh_commit in github.get_repo_commits_except_merges(
organization, repository, {'since': commit_created_at},
):
commit = Contribution.objects.create(
Expand Down
2 changes: 1 addition & 1 deletion contributors/views/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from contributors.views import ( # noqa: WPS235
from contributors.views import (
about,
achievements,
config,
Expand Down
2 changes: 1 addition & 1 deletion contributors/views/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def collect_data(request):
repo.is_visible = True
Repository.objects.bulk_update(repos, ['is_tracked', 'is_visible'])
fetch_command = ['./manage.py', 'fetchdata', '--repo']
fetch_command.extend([repo.full_name for repo in repos]) # noqa: WPS441,E501
fetch_command.extend([repo.full_name for repo in repos]) # noqa: E501
subprocess.Popen(fetch_command) # noqa: S603
return TemplateResponse(request, 'admin/data_collection.html', context)
return HttpResponseForbidden("Forbidden.")
4 changes: 2 additions & 2 deletions contributors/views/contributor_compare.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.db.models import Count, Q # noqa: WPS347
from django.db.models import Count, Q
from django.views.generic import ListView

from contributors.models import Contribution, Contributor, Repository
Expand All @@ -18,7 +18,7 @@ def get_queryset(self):
contributor=Contributor.objects.filter(
login=self.request.path.split('/')[-2],
).first(),
) # noqa: WPS221
)
qs_me = Contribution.objects.filter(
contributor=Contributor.objects.get(login=self.request.user),
)
Expand Down
4 changes: 2 additions & 2 deletions contributors/views/contributors_views/contributor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.db.models import Count, F, Q, Sum # noqa: WPS347
from django.db.models import Count, F, Q, Sum
from django.db.models.functions import Coalesce
from django.views import generic

Expand Down Expand Up @@ -46,7 +46,7 @@ def get_context_data(self, **kwargs):
self.object.contribution_set.for_year()
)
context['top_repository'] = repositories.annotate(
summary=F('commits') + F('pull_requests') + F('issues') + F('comments'), # noqa: WPS221, E501
summary=F('commits') + F('pull_requests') + F('issues') + F('comments'), # noqa: E501
).order_by('-summary').first()

context['summary'] = Contribution.objects.filter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ListView(TableSortSearchAndPaginationMixin, generic.ListView):
)
ordering = sortable_fields[0]

def get_queryset(self): # noqa: WPS615
def get_queryset(self):
"""Get issues from contributions.
Returns:
Expand Down
2 changes: 1 addition & 1 deletion contributors/views/contributors_views/contributor_prs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ListView(TableSortSearchAndPaginationMixin, generic.ListView):
)
ordering = sortable_fields[0]

def get_queryset(self): # noqa: WPS615
def get_queryset(self):
"""Get pull requests from contributions.
Returns:
Expand Down
2 changes: 1 addition & 1 deletion contributors/views/contributors_views/contributors.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_context_data(self, **kwargs):
context['form_org'] = CombinedSearchForm(self.request.GET)
return context

def get_queryset(self): # noqa: WPS615
def get_queryset(self):
"""Get filter queryset."""
queryset = super().get_queryset().prefetch_related(
'contributors__organization',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_context_data(self, **kwargs):
context['is_month'] = self.extra_context.get('period') == 'month'
return context

def get_queryset(self): # noqa: WPS615
def get_queryset(self):
"""Modify queryset depending on extra_content.period value."""
if self.extra_context.get('period') == 'week':
self.queryset = Contributor.objects.visible_with_weekly_stats()
Expand Down
8 changes: 4 additions & 4 deletions contributors/views/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class IssuesFilter(django_filters.FilterSet):
label='good first issue',
)

class Meta: # noqa: WPS306
class Meta:
model = Contribution
fields = [
'info_title',
Expand All @@ -65,7 +65,7 @@ class Meta: # noqa: WPS306
'info_state',
]

def get_good_first_issue(self, queryset, name, value): # noqa: WPS110
def get_good_first_issue(self, queryset, name, value):
"""Filter issues by label 'good_first_issue'."""
if value: # Only apply filter if checkbox is checked
good_first = ContributionLabel.objects.filter(
Expand All @@ -90,13 +90,13 @@ class DetailTablePeriodFilter(django_filters.FilterSet):
field_name='period_filter',
)

def get_contributions_by_period(self, queryset, name, value): # noqa: WPS110, E501
def get_contributions_by_period(self, queryset, name, value):
"""Contributions filter for a period."""
if value == 'for_year':
datetime_now = timezone.now()
date_eleven_months_ago = (
datetime_now - relativedelta.relativedelta(
months=11, day=1, # noqa: WPS432
months=11, day=1,
)
).date()
queryset = queryset.filter(
Expand Down
4 changes: 2 additions & 2 deletions contributors/views/generic_list_views/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ListView(

template_name = 'contributors_sections/issues/open_issues.html'
filterset_class = IssuesFilter
sortable_fields = ( # noqa: WPS317
sortable_fields = (
'info__title',
'repository__full_name',
'repository__labels',
Expand All @@ -38,7 +38,7 @@ class ListView(
queryset=ContributionLabel.objects.all(),
)

def get_queryset(self): # noqa: WPS615
def get_queryset(self):
"""Get the initial queryset and apply all filters."""
queryset = (
Contribution.objects.filter(type='iss').
Expand Down
2 changes: 1 addition & 1 deletion contributors/views/generic_list_views/pull_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ListView(TableSortSearchAndPaginationMixin, generic.ListView):

template_name = 'contributors_sections/pull_requests/pull_requests_list.html' # noqa: E501

def get_queryset(self): # noqa: WPS615
def get_queryset(self):
"""Get pull requests.
Returns:
Expand Down
2 changes: 1 addition & 1 deletion contributors/views/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class HomeView(TemplateView):

template_name = 'home.html'

def get_context_data(self, **kwargs): # noqa: WPS210
def get_context_data(self, **kwargs):
"""Add context."""
context = super().get_context_data(**kwargs)

Expand Down
Loading

0 comments on commit 0d632a9

Please sign in to comment.