Skip to content
Open
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
19 changes: 5 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,19 @@ repos:
- id: django-upgrade
args: [--target-version, "6.0"]

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.12.0
hooks:
- id: black
args: ["--target-version=py312"]

- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.7.4
hooks:
- id: prettier
exclude_types: [html, json, scss]
exclude: '(^djangoproject\/static\/js\/lib\/.*$|^checklists\/templates\/.*$)'

- repo: https://github.com/pycqa/isort
rev: 7.0.0
hooks:
- id: isort

- repo: https://github.com/pycqa/flake8
rev: 7.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.10
hooks:
- id: flake8
- id: ruff
args: ["--fix"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you are dropping flake8, you might want to add ruff-check too.

- id: ruff-format

- repo: https://github.com/rtts/djhtml
rev: 3.0.10
Expand Down
1 change: 0 additions & 1 deletion accounts/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
Expand Down
1 change: 0 additions & 1 deletion accounts/migrations/0002_migrate_sha1_passwords.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


class Migration(migrations.Migration):

dependencies = [
("accounts", "0001_initial"),
("auth", "0007_alter_validators_add_error_messages"),
Expand Down
1 change: 0 additions & 1 deletion accounts/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ def test_caches_trac_stats(self):


class ViewsTests(ReleaseMixin, TestCase):

def test_login_redirect(self):
credentials = {"username": "a-user", "password": "password"}
User.objects.create_user(**credentials)
Expand Down
3 changes: 1 addition & 2 deletions aggregator/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class FeedModelForm(forms.ModelForm):
attrs={
"class": "required",
"placeholder": _(
"Link to the RSS/Atom feed. Please only use "
"Django-specific feeds."
"Link to the RSS/Atom feed. Please only use Django-specific feeds."
),
}
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ def handle(self, **kwargs):
feeds = Feed.objects.filter(approval_status=PENDING_FEED)
to_email = [
x.email
for x in User.objects.filter(
groups__name=settings.FEED_APPROVERS_GROUP_NAME
)
for x in User.objects.filter(groups__name=settings.FEED_APPROVERS_GROUP_NAME)
]

if len(feeds) == 0:
Expand Down
1 change: 0 additions & 1 deletion aggregator/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
Expand Down
1 change: 0 additions & 1 deletion aggregator/migrations/0002_add_feed_approver_auth_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def reverse_func(apps, schema_editor):


class Migration(migrations.Migration):

dependencies = [
("aggregator", "0001_initial"),
]
Expand Down
1 change: 0 additions & 1 deletion aggregator/migrations/0003_increase_url_max_length.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


class Migration(migrations.Migration):

dependencies = [
("aggregator", "0002_add_feed_approver_auth_group"),
]
Expand Down
9 changes: 2 additions & 7 deletions aggregator/migrations/0004_add_local_django_community.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
("aggregator", "0003_increase_url_max_length"),
]
Expand Down Expand Up @@ -45,15 +44,11 @@ class Migration(migrations.Migration):
),
(
"website_url",
models.URLField(
blank=True, default=None, max_length=250, null=True
),
models.URLField(blank=True, default=None, max_length=250, null=True),
),
(
"event_site_url",
models.URLField(
blank=True, default=None, max_length=250, null=True
),
models.URLField(blank=True, default=None, max_length=250, null=True),
),
("is_active", models.BooleanField(default=True)),
("created_at", models.DateTimeField(auto_now_add=True)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("aggregator", "0004_add_local_django_community"),
]
Expand Down
1 change: 0 additions & 1 deletion aggregator/migrations/0006_localdjangocommunity_plural.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("aggregator", "0005_feeditem_add_index_date_modified"),
]
Expand Down
16 changes: 4 additions & 12 deletions aggregator/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,11 @@ def get_absolute_url(self):


def feed_updated(sender, notification, **kwargs):
log.debug(
"Received notification on subscription ID %s (%s)", sender.id, sender.topic
)
log.debug("Received notification on subscription ID %s (%s)", sender.id, sender.topic)
try:
feed = Feed.objects.get(feed_url=sender.topic)
except Feed.DoesNotExist:
log.error(
"Subscription ID %s (%s) doesn't have a feed.", sender.id, sender.topic
)
log.error("Subscription ID %s (%s) doesn't have a feed.", sender.id, sender.topic)
return

notification = feedparser.parse(notification)
Expand Down Expand Up @@ -219,9 +215,7 @@ class LocalDjangoCommunity(models.Model):
country = CountryField()
continent = models.CharField(choices=CONTINENTS, max_length=15)
website_url = models.URLField(max_length=250, default=None, blank=True, null=True)
event_site_url = models.URLField(
max_length=250, default=None, blank=True, null=True
)
event_site_url = models.URLField(max_length=250, default=None, blank=True, null=True)
is_active = models.BooleanField(default=True)
created_at = models.DateTimeField(auto_now_add=True)

Expand All @@ -240,9 +234,7 @@ class Meta:

def clean(self):
if not self.website_url and not self.event_site_url:
raise ValidationError(
"You must provide at least a website or event site URL"
)
raise ValidationError("You must provide at least a website or event site URL")

def __str__(self):
return self.name
1 change: 0 additions & 1 deletion blog/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


class Migration(migrations.Migration):

dependencies = []

operations = [
Expand Down
1 change: 0 additions & 1 deletion blog/migrations/0002_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


class Migration(migrations.Migration):

dependencies = [
("blog", "0001_initial"),
]
Expand Down
1 change: 0 additions & 1 deletion blog/migrations/0003_entry_content_format_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("blog", "0002_event"),
]
Expand Down
1 change: 0 additions & 1 deletion blog/migrations/0004_imageupload.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

dependencies = [
("blog", "0003_entry_content_format_markdown"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
Expand Down
1 change: 0 additions & 1 deletion blog/migrations/0005_entry_social_media_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
("blog", "0004_imageupload"),
]
Expand Down
1 change: 0 additions & 1 deletion blog/migrations/0006_entry_is_searchable.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("blog", "0005_entry_social_media_card"),
]
Expand Down
4 changes: 1 addition & 3 deletions blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ class Entry(models.Model):
)
is_searchable = models.BooleanField(
default=False,
help_text=_(
"Tick to make this entry appear in the Django documentation search."
),
help_text=_("Tick to make this entry appear in the Django documentation search."),
)
pub_date = models.DateTimeField(
verbose_name=_("Publication date"),
Expand Down
4 changes: 1 addition & 3 deletions blog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ class BlogDateDetailView(BlogViewMixin, DateDetailView):

def get_queryset(self):
"""Allows staff users with blog write permission to view unpublished entries."""
if self.request.user.is_staff and self.request.user.has_perm(
"blog.change_entry"
):
if self.request.user.is_staff and self.request.user.has_perm("blog.change_entry"):
return Entry.objects.all()
else:
return super().get_queryset()
Expand Down
5 changes: 1 addition & 4 deletions checklists/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = [
Expand Down Expand Up @@ -62,9 +61,7 @@ class Migration(migrations.Migration):
),
(
"summary",
models.CharField(
help_text="Single backticks here.", max_length=1024
),
models.CharField(help_text="Single backticks here.", max_length=1024),
),
(
"description",
Expand Down
7 changes: 2 additions & 5 deletions checklists/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,7 @@ class SecurityIssueReleasesThrough(models.Model):
"SecurityIssue", on_delete=models.CASCADE, verbose_name="Security Issue"
)
release = models.ForeignKey(Release, on_delete=models.CASCADE)
commit_hash = models.CharField(
max_length=128, default="", blank=True, db_index=True
)
commit_hash = models.CharField(max_length=128, default="", blank=True, db_index=True)

objects = SecurityIssueReleasesThroughManager()

Expand Down Expand Up @@ -744,8 +742,7 @@ def cve_description(self):
@cached_property
def cve_html_description(self):
return "".join(
f"<p>{line.strip()}</p>"
for line in urlize(self.cve_description).split("\n")
f"<p>{line.strip()}</p>" for line in urlize(self.cve_description).split("\n")
)

@property
Expand Down
1 change: 0 additions & 1 deletion checklists/tests/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@


class Factory:

def make_user(self, perm_names=None, **kwargs):
username = kwargs.setdefault("username", f"username-{uuid4()}")
kwargs.setdefault("email", f"{username}@example.com")
Expand Down
22 changes: 6 additions & 16 deletions checklists/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import json
import re
import zoneinfo
from datetime import UTC, date, datetime

import zoneinfo
from django.db import IntegrityError
from django.template.loader import render_to_string
from django.test import RequestFactory, TestCase, override_settings
Expand Down Expand Up @@ -138,9 +138,7 @@ def test_blogpost_properties(self):
release = self.factory.make_release(version="5.2.4")
checklist = self.make_checklist(release=release)
self.assertEqual(checklist.slug, "bugfix-releases")
self.assertEqual(
checklist.blogpost_title, "Django bugfix release issued: 5.2.4"
)
self.assertEqual(checklist.blogpost_title, "Django bugfix release issued: 5.2.4")
self.assertEqual(
checklist.blogpost_summary,
"Today the Django project issued a bugfix release for the 5.2 release "
Expand Down Expand Up @@ -172,9 +170,7 @@ def test_affected_releases(self):
release52 = self.factory.make_release(version="5.2")
prerelease = self.factory.make_release(version="6.0a1")
checklist = self.make_checklist(releases=[release51, release52, prerelease])
self.assertEqual(
checklist.affected_releases, [prerelease, release52, release51]
)
self.assertEqual(checklist.affected_releases, [prerelease, release52, release51])

def test_blogpost_info(self):
release42 = self.factory.make_release(version="4.2.13")
Expand Down Expand Up @@ -332,14 +328,10 @@ def test_render_checklist_simple(self):
)

with self.subTest(task="Stub release notes added"):
self.assertStubReleaseNotesAdded(
checklist.latest_release, checklist_content
)
self.assertStubReleaseNotesAdded(checklist.latest_release, checklist_content)

with self.subTest(task="Make release public steps added"):
self.assertMakeReleasePublicAdded(
checklist.latest_release, checklist_content
)
self.assertMakeReleasePublicAdded(checklist.latest_release, checklist_content)

with self.subTest(task="Push and announce steps added"):
self.assertPushAndAnnouncesAdded(checklist, checklist_content)
Expand Down Expand Up @@ -856,9 +848,7 @@ def test_render_checklist(self):
)
assert instance.release is release
checklist_content = self.do_render_checklist(instance)
self.assertIn(
"- [ ] Update the translation catalogs:", checklist_content
)
self.assertIn("- [ ] Update the translation catalogs:", checklist_content)
if status == "rc":
self.assertIn(
"- [ ] Create a new topic in the `Internationalization` "
Expand Down
4 changes: 1 addition & 3 deletions dashboard/management/commands/update_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ def handle(self, **options):
for MC in Metric.__subclasses__():
for metric in MC.objects.all():
if verbose:
self.stdout.write(
"Updating %s ... " % metric.name.lower(), ending=""
)
self.stdout.write("Updating %s ... " % metric.name.lower(), ending="")
datum = metric.data.create(measurement=metric.fetch())
if verbose:
print(datum.measurement)
Expand Down
1 change: 0 additions & 1 deletion dashboard/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
("contenttypes", "0001_initial"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("dashboard", "0001_initial"),
]
Expand Down
Loading