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

Ruff django rule #512

Merged
merged 5 commits into from
Jul 20, 2024
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
6 changes: 4 additions & 2 deletions main/templatetags/details_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from django import template
from django.conf import settings
from django.utils.html import format_html

from main.templatetags import pgp
from main.utils import gitlab_project_name_to_path
Expand All @@ -18,9 +19,10 @@ def link_encode(url, query):
return "%s?%s" % (url, data)


@register.inclusion_tag('packages/details_link.html')
@register.simple_tag
def details_link(pkg):
return {'pkg': pkg}
link = '<a href="%s" title="View package details for %s">%s</a>'
return format_html(link % (pkg.get_absolute_url(), pkg.pkgname, pkg.pkgname))


@register.simple_tag
Expand Down
12 changes: 7 additions & 5 deletions packages/views/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ def details(request, name='', repo='', arch=''):
pkg = Package.objects.select_related(
'arch', 'repo', 'packager').get(pkgname=name,
repo=repo_obj, arch=arch_obj)
rbstatus = None
try:
rbstatus = RebuilderdStatus.objects.get(pkg=pkg)
except RebuilderdStatus.DoesNotExist:
pass
if request.method == 'HEAD':
return empty_response()

rbstatus = None
if request.user.is_authenticated:
try:
rbstatus = RebuilderdStatus.objects.get(pkg=pkg)
except RebuilderdStatus.DoesNotExist:
pass
return render(request, 'packages/details.html', {'pkg': pkg, 'rbstatus': rbstatus,
'notreproducible': rbstatus.status == RebuilderdStatus.BAD if rbstatus else False})
except Package.DoesNotExist:
Expand Down
2 changes: 1 addition & 1 deletion public/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def feeds(request):
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')
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: 6 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ select = [
"A", # flake8-builtins
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"DJ", # flake8-django
"E", # pycodestyle
"F", # pyflakes
"G", # flake8-logging-format
Expand All @@ -27,4 +28,9 @@ ignore = [
"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`
# TODO: add these one by one
"DJ001", # Avoid using `null=True` on string-based fields such as `CharField`
"DJ006", # Do not use `exclude` with `ModelForm`, use `fields` instead
"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`
]
1 change: 0 additions & 1 deletion templates/packages/details_link.html

This file was deleted.

Loading