Skip to content

Commit

Permalink
treewide: reduce line length to 118
Browse files Browse the repository at this point in the history
  • Loading branch information
jelly committed Jan 18, 2025
1 parent 2908601 commit 25dd94b
Show file tree
Hide file tree
Showing 18 changed files with 58 additions and 23 deletions.
3 changes: 2 additions & 1 deletion devel/management/commands/archweb_inotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def run():
retry = False
except OperationalError as exc:
retry_count += 1
logger.error('Unable to update database \'%s\', retrying=%d', self.path, retry_count, exc_info=exc)
logger.error('Unable to update database \'%s\', retrying=%d',
self.path, retry_count, exc_info=exc)
time.sleep(5)

if retry_count == self.retry_limit:
Expand Down
4 changes: 3 additions & 1 deletion devel/management/commands/readlinks_inotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def setup_notifier(self):
for name in all_paths:
manager.add_watch(name, mask)

handler = EventHandler(arch_paths=arch_path_map, filename_suffix='.links.tar.gz', callback_func=wrapper_read_links)
handler = EventHandler(arch_paths=arch_path_map,
filename_suffix='.links.tar.gz',
callback_func=wrapper_read_links)
return pyinotify.Notifier(manager, handler)


Expand Down
4 changes: 3 additions & 1 deletion devel/management/commands/reporead.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,9 @@ def parse_info(pkgname, filename, iofile):
elif blockname:
store[blockname].append(line)
else:
raise Exception("%s: Read package info outside a block while reading from %s: %s" % (pkgname, filename, line))
raise Exception("%s: Read package info outside a block while reading from %s: %s" % (pkgname,
filename,
line))
return store


Expand Down
1 change: 1 addition & 0 deletions devel/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import zoneinfo

from django.contrib.auth.models import Group, User
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
Expand Down
5 changes: 3 additions & 2 deletions devel/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ def non_existing_dependencies(packages):


def non_reproducible_packages(packages):
statuses = RebuilderdStatus.objects.select_related().filter(status=RebuilderdStatus.BAD, pkg__pkgname__in=packages.values('pkgname'))
statuses = RebuilderdStatus.objects.select_related().filter(status=RebuilderdStatus.BAD,
pkg__pkgname__in=packages.values('pkgname'))
return linkify_non_reproducible_packages(statuses)


Expand All @@ -227,7 +228,7 @@ def orphan_dependencies(packages):
JOIN packages_packagerelation ppr ON pp.pkgbase = ppr.pkgbase
JOIN (SELECT DISTINCT cp.pkgname FROM packages cp LEFT JOIN packages_packagerelation pr ON cp.pkgbase = pr.pkgbase WHERE pr.id IS NULL) child ON ppd.name = child.pkgname
ORDER BY child.pkgname;
"""
""" # noqa: E501
cursor.execute(query)

for row in cursor.fetchall():
Expand Down
4 changes: 3 additions & 1 deletion devel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ def tier0_mirror_auth(request):
token = credentials[1]

groups = Group.objects.filter(name__in=SELECTED_GROUPS)
user = User.objects.filter(username=username, is_active=True, groups__in=groups).select_related('userprofile').first()
user = User.objects.filter(username=username,
is_active=True,
groups__in=groups).select_related('userprofile').first()
if not user:
return unauthorized

Expand Down
3 changes: 2 additions & 1 deletion main/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ def grouper(depend):
dep_pkgs = list(dep_pkgs)
dep = dep_pkgs[0]
if len(dep_pkgs) > 1:
dep_pkgs = [d for d in dep_pkgs if d.pkg.repo.testing == self.repo.testing and d.pkg.repo.staging == self.repo.staging]
dep_pkgs = [d for d in dep_pkgs if d.pkg.repo.testing == self.repo.testing and \
d.pkg.repo.staging == self.repo.staging]
if len(dep_pkgs) > 0:
dep = dep_pkgs[0]
trimmed.append(dep)
Expand Down
3 changes: 2 additions & 1 deletion main/storage.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import cssmin
import jsmin
from django.contrib.staticfiles.storage import ManifestStaticFilesStorage
from django.core.files.base import ContentFile
from django.utils.encoding import smart_str

import cssmin


class MinifiedStaticFilesStorage(ManifestStaticFilesStorage):
"""
Expand Down
4 changes: 3 additions & 1 deletion main/templatetags/pgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def pgp_key_link(key_id, link_text=None):
return format_key(key_id)
pgp_server_secure = getattr(settings, 'PGP_SERVER_SECURE', False)
scheme = 'https' if pgp_server_secure else 'http'
url = '%s://%s/pks/lookup?op=vindex&fingerprint=on&exact=on&search=0x%s' % (scheme, pgp_server, key_id)
url = '%s://%s/pks/lookup?op=vindex&fingerprint=on&exact=on&search=0x%s' % (scheme,
pgp_server,
key_id)
if link_text is None:
link_text = '0x%s' % key_id[-8:]
values = (url, format_key(key_id), link_text)
Expand Down
3 changes: 2 additions & 1 deletion news/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ def form_valid(self, form):
if settings.MAILMAN_PASSWORD:
headers['Approved'] = settings.MAILMAN_PASSWORD
template = loader.get_template('news/news_email_notification.txt')
from_=f'"Arch Linux: Recent news updates: {newsitem.author.get_full_name()}" <{settings.ANNOUNCE_EMAIL}>'
EmailMessage(
subject=f'[arch-announce] {newsitem.title}',
body=template.render(ctx),
from_email=f'"Arch Linux: Recent news updates: {newsitem.author.get_full_name()}" <{settings.ANNOUNCE_EMAIL}>',
from_email=from_,
to=[settings.ANNOUNCE_EMAIL],
headers=headers).send()
return super(NewsCreateView, self).form_valid(form)
Expand Down
6 changes: 4 additions & 2 deletions packages/management/commands/populate_signoffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def create_specification(package, log, finder):


def get_tag_info(repo, pkgbase, version):
# Gitlab requires the path to the gitlab repo to be html encoded and project name encoded in a different special way
# Gitlab requires the path to the gitlab repo to be html encoded and
# project name encoded in a different special way
pkgrepo = urllib.parse.quote_plus(f'{settings.GITLAB_PACKAGE_REPO}/') + gitlab_project_name_to_path(pkgbase)
url = f'https://{settings.GITLAB_INSTANCE}/api/v4/projects/{pkgrepo}/repository/tags'

Expand Down Expand Up @@ -112,7 +113,8 @@ def cleanup_signoff_comments():
id_signoffs = [signoff.id for g in groups for signoff in g.signoffs]
logger.info("Keeping %s signoffs", len(id_signoffs))
# FakeSignoffSpecification's have no id
id_signoffspecs = [g.specification.id for g in groups if not isinstance(g.specification, FakeSignoffSpecification)]
id_signoffspecs = [g.specification.id for g in groups if not isinstance(g.specification,
FakeSignoffSpecification)]
logger.info("Keeping %s signoffspecifications", len(id_signoffspecs))

Signoff.objects.exclude(id__in=id_signoffs).delete()
Expand Down
6 changes: 4 additions & 2 deletions packages/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ def log_update(self, old_pkg, new_pkg):
if new_pkg:
update.action_flag = CHANGE
# ensure we should even be logging this
if old_pkg.pkgver == new_pkg.pkgver and old_pkg.pkgrel == new_pkg.pkgrel and old_pkg.epoch == new_pkg.epoch:
if old_pkg.pkgver == new_pkg.pkgver and old_pkg.pkgrel == new_pkg.pkgrel \
and old_pkg.epoch == new_pkg.epoch:
# all relevant fields were the same; e.g. a force update
return
else:
Expand Down Expand Up @@ -395,7 +396,8 @@ def get_best_satisfier(self):
# actually satisfy the requirements
if self.comparison and self.version:
alpm = AlpmAPI()
pkgs = [pkg for pkg in pkgs if not alpm.available or alpm.compare_versions(pkg.full_version, self.comparison, self.version)]
pkgs = [pkg for pkg in pkgs if not alpm.available or alpm.compare_versions(pkg.full_version,
self.comparison, self.version)]
if len(pkgs) == 0:
# couldn't find a package in the DB
# it should be a virtual depend (or a removed package)
Expand Down
10 changes: 8 additions & 2 deletions packages/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,14 @@ def sonames(request):
name = request.GET.get('name')

if name:
sonames = Soname.objects.filter(name__startswith=name).values('pkg__pkgname', 'pkg__pkgver', 'pkg__pkgrel', 'pkg__epoch', 'pkg__repo__name')
packages = [{'pkgname': soname['pkg__pkgname'], 'pkgrel': soname['pkg__pkgrel'], 'pkgver': soname['pkg__pkgver'], 'epoch': soname['pkg__epoch'], 'repo': soname['pkg__repo__name'].lower()} for soname in sonames]
sonames = Soname.objects.filter(name__startswith=name).values('pkg__pkgname',
'pkg__pkgver',
'pkg__pkgrel',
'pkg__epoch',
'pkg__repo__name')
packages = [{'pkgname': soname['pkg__pkgname'], 'pkgrel': soname['pkg__pkgrel'],
'pkgver': soname['pkg__pkgver'], 'epoch': soname['pkg__epoch'],
'repo': soname['pkg__repo__name'].lower()} for soname in sonames]
else:
return HttpResponseBadRequest('name parameter is required')

Expand Down
3 changes: 2 additions & 1 deletion packages/views/flag.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def clean_message(self):
# make sure the message isn't garbage (only punctuation or whitespace)
# or spam (using a simple denylist)
# and ensure a certain minimum length
if re.match(r'^[^0-9A-Za-z]+$', data) or any(fd.keyword in data for fd in FlagDenylist.objects.all()) or len(data) < 3:
if re.match(r'^[^0-9A-Za-z]+$', data) or any(fd.keyword in data for fd in FlagDenylist.objects.all()) \
or len(data) < 3:
raise forms.ValidationError("Enter a valid and useful out-of-date message.")
return data

Expand Down
5 changes: 3 additions & 2 deletions public/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ def feeds(request):
@cache_control(max_age=307)
def keys(request):
profile_ids = UserProfile.allowed_repos.through.objects.values('userprofile_id')
users = User.objects.filter(
is_active=True, userprofile__id__in=profile_ids).order_by('first_name', 'last_name').select_related('userprofile')
users = User.objects.filter(is_active=True,
userprofile__id__in=profile_ids).order_by('first_name',
'last_name').select_related('userprofile')
user_key_ids = frozenset(user.userprofile.pgp_key[-16:] for user in users
if user.userprofile.pgp_key)

Expand Down
6 changes: 4 additions & 2 deletions releng/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
releases_patterns = [
path('', ReleaseListView.as_view(), name='releng-release-list'),
path('json/', views.releases_json, name='releng-release-list-json'),
re_path(r'^(?P<version>[-.\w]+)/$', cache_page(311)(ReleaseDetailView.as_view()), name='releng-release-detail'),
re_path(r'^(?P<version>[-.\w]+)/torrent/$', cache_page(311)(views.release_torrent), name='releng-release-torrent'),
re_path(r'^(?P<version>[-.\w]+)/$', cache_page(311)(ReleaseDetailView.as_view()),
name='releng-release-detail'),
re_path(r'^(?P<version>[-.\w]+)/torrent/$', cache_page(311)(views.release_torrent),
name='releng-release-torrent'),
]

netboot_patterns = [
Expand Down
7 changes: 6 additions & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ select = [
]

ignore = [
"E501", # line lengt violation
# "E501", # line lengt violation
"E731", # Do not assign a `lambda` expression, use a `def`
"B904", # Within an `except` clause, raise exceptions with `raise ... from err`
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
Expand All @@ -34,3 +34,8 @@ ignore = [
"DJ008", # Model does not define `__str__` method
"DJ012", # Order of model's inner classes, methods, and fields does not follow the Django Style Guide: `Meta` class should come before `get_absolute_url`
]

# Ignore Django migrations
exclude = [
"*/migrations/*.py"
]
4 changes: 3 additions & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@
INSTALLED_APPS = [*list(INSTALLED_APPS), 'debug_toolbar']

if PROMETHEUS_METRICS:
MIDDLEWARE = ['django_prometheus.middleware.PrometheusBeforeMiddleware', *list(MIDDLEWARE), 'django_prometheus.middleware.PrometheusAfterMiddleware']
MIDDLEWARE = ['django_prometheus.middleware.PrometheusBeforeMiddleware',
*list(MIDDLEWARE),
'django_prometheus.middleware.PrometheusAfterMiddleware']

INSTALLED_APPS = [*list(INSTALLED_APPS), 'django_prometheus']

Expand Down

0 comments on commit 25dd94b

Please sign in to comment.