Skip to content

Commit ac85548

Browse files
authored
Format parens (#347)
Remove some unnecessary parens generated by ruff format
1 parent f3c5ba5 commit ac85548

File tree

14 files changed

+58
-104
lines changed

14 files changed

+58
-104
lines changed

spirit/category/tests.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,11 @@ def test_category_detail_view(self):
3636
topic2 = utils.create_topic(category=self.subcategory_1)
3737
topic3 = utils.create_topic(category=self.category_1)
3838

39-
(
40-
Topic.objects.filter(pk=topic.pk).update(
41-
last_active=timezone.now() - datetime.timedelta(days=10)
42-
)
39+
Topic.objects.filter(pk=topic.pk).update(
40+
last_active=timezone.now() - datetime.timedelta(days=10)
4341
)
44-
(
45-
Topic.objects.filter(pk=topic3.pk).update(
46-
last_active=timezone.now() - datetime.timedelta(days=5)
47-
)
42+
Topic.objects.filter(pk=topic3.pk).update(
43+
last_active=timezone.now() - datetime.timedelta(days=5)
4844
)
4945

5046
response = self.client.get(
@@ -63,10 +59,8 @@ def test_category_detail_view_order(self):
6359
topic_b = utils.create_topic(category=self.category_1)
6460
utils.create_topic(category=self.category_1, is_pinned=True, is_removed=True)
6561
# show pinned first
66-
(
67-
Topic.objects.filter(pk=topic_a.pk).update(
68-
last_active=timezone.now() - datetime.timedelta(days=10)
69-
)
62+
Topic.objects.filter(pk=topic_a.pk).update(
63+
last_active=timezone.now() - datetime.timedelta(days=10)
7064
)
7165

7266
response = self.client.get(
@@ -87,10 +81,8 @@ def test_category_detail_view_pinned(self):
8781
topic_c = utils.create_topic(category=category)
8882
topic_d = utils.create_topic(category=category, is_globally_pinned=True)
8983
# show globally pinned first
90-
(
91-
Topic.objects.filter(pk=topic_d.pk).update(
92-
last_active=timezone.now() - datetime.timedelta(days=10)
93-
)
84+
Topic.objects.filter(pk=topic_d.pk).update(
85+
last_active=timezone.now() - datetime.timedelta(days=10)
9486
)
9587

9688
response = self.client.get(

spirit/comment/models.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,16 @@ def like(self):
5555
return
5656

5757
def increase_modified_count(self):
58-
(
59-
Comment.objects.filter(pk=self.pk).update(
60-
modified_count=F("modified_count") + 1
61-
)
58+
Comment.objects.filter(pk=self.pk).update(
59+
modified_count=F("modified_count") + 1
6260
)
6361

6462
def increase_likes_count(self):
65-
(Comment.objects.filter(pk=self.pk).update(likes_count=F("likes_count") + 1))
63+
Comment.objects.filter(pk=self.pk).update(likes_count=F("likes_count") + 1)
6664

6765
def decrease_likes_count(self):
68-
(
69-
Comment.objects.filter(pk=self.pk, likes_count__gt=0).update(
70-
likes_count=F("likes_count") - 1
71-
)
66+
Comment.objects.filter(pk=self.pk, likes_count__gt=0).update(
67+
likes_count=F("likes_count") - 1
7268
)
7369

7470
@classmethod

spirit/comment/poll/forms.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,8 @@ def save_m2m(self):
7474
if not self.poll.is_multiple_choice:
7575
choices = [choices]
7676

77-
(
78-
CommentPollVote.objects.filter(
79-
voter=self.user, choice__poll=self.poll
80-
).update(is_removed=True)
77+
CommentPollVote.objects.filter(voter=self.user, choice__poll=self.poll).update(
78+
is_removed=True
8179
)
8280

8381
for choice_id in choices:

spirit/comment/poll/models.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def total_votes(self):
9393

9494
@classmethod
9595
def update_or_create_many(cls, comment, polls_raw):
96-
(cls.objects.for_comment(comment).update(is_removed=True))
96+
cls.objects.for_comment(comment).update(is_removed=True)
9797

9898
default_fields = ["title", "choice_min", "choice_max", "close_at", "mode"]
9999

@@ -148,23 +148,19 @@ def votes_percentage(self):
148148

149149
@classmethod
150150
def increase_vote_count(cls, poll, voter):
151-
(
152-
cls.objects.for_vote(poll=poll, voter=voter).update(
153-
vote_count=F("vote_count") + 1
154-
)
151+
cls.objects.for_vote(poll=poll, voter=voter).update(
152+
vote_count=F("vote_count") + 1
155153
)
156154

157155
@classmethod
158156
def decrease_vote_count(cls, poll, voter):
159-
(
160-
cls.objects.for_vote(poll=poll, voter=voter).update(
161-
vote_count=F("vote_count") - 1
162-
)
157+
cls.objects.for_vote(poll=poll, voter=voter).update(
158+
vote_count=F("vote_count") - 1
163159
)
164160

165161
@classmethod
166162
def update_or_create_many(cls, comment, choices_raw):
167-
(cls.objects.for_comment(comment).update(is_removed=True))
163+
cls.objects.for_comment(comment).update(is_removed=True)
168164

169165
if not choices_raw: # Avoid the later transaction.atomic()
170166
return

spirit/comment/poll/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def close_or_open(request, pk, close=True):
2626
else:
2727
close_at = None
2828

29-
(CommentPoll.objects.filter(pk=poll.pk).update(close_at=close_at))
29+
CommentPoll.objects.filter(pk=poll.pk).update(close_at=close_at)
3030

3131
return safe_redirect(request, "next", poll.get_absolute_url())
3232

spirit/comment/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def update(request, pk):
7676
def delete(request, pk, remove=True):
7777
comment = get_object_or_404(Comment, pk=pk)
7878
if is_post(request):
79-
(Comment.objects.filter(pk=pk).update(is_removed=remove))
79+
Comment.objects.filter(pk=pk).update(is_removed=remove)
8080
return safe_redirect(request, "next", comment.get_absolute_url())
8181
return render(
8282
request=request,

spirit/core/utils/timezone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,6 @@ def timezones():
9696

9797
for offset, time_zone in timezones_by_offset():
9898
zone, pretty_time_zone = timezone_format(time_zone, offset)
99-
(timezones_cache.setdefault(zone, []).append((time_zone, pretty_time_zone)))
99+
timezones_cache.setdefault(zone, []).append((time_zone, pretty_time_zone))
100100

101101
return sorted(timezones_cache.items(), key=lambda x: x[0])

spirit/topic/models.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,16 @@ def is_visited(self):
102102
return bool(self.bookmark)
103103

104104
def increase_view_count(self):
105-
(Topic.objects.filter(pk=self.pk).update(view_count=F("view_count") + 1))
105+
Topic.objects.filter(pk=self.pk).update(view_count=F("view_count") + 1)
106106

107107
def increase_comment_count(self):
108-
(
109-
Topic.objects.filter(pk=self.pk).update(
110-
comment_count=F("comment_count") + 1, last_active=timezone.now()
111-
)
108+
Topic.objects.filter(pk=self.pk).update(
109+
comment_count=F("comment_count") + 1, last_active=timezone.now()
112110
)
113111

114112
def decrease_comment_count(self):
115113
# todo: update last_active to last() comment
116-
(Topic.objects.filter(pk=self.pk).update(comment_count=F("comment_count") - 1))
114+
Topic.objects.filter(pk=self.pk).update(comment_count=F("comment_count") - 1)
117115

118116
def get_all_comments_html(self):
119117
"""

spirit/topic/notification/models.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def mark_as_read(cls, user, topic):
5959
if not user.is_authenticated:
6060
return
6161

62-
(cls.objects.filter(user=user, topic=topic).update(is_read=True))
62+
cls.objects.filter(user=user, topic=topic).update(is_read=True)
6363

6464
@classmethod
6565
def create_maybe(cls, user, comment, is_read=True, action=COMMENT):
@@ -104,12 +104,10 @@ def notify_new_mentions(cls, comment, mentions):
104104
except IntegrityError:
105105
pass
106106

107-
(
108-
cls.objects.filter(
109-
user__in=tuple(mentions.values()), topic=comment.topic, is_read=True
110-
).update(
111-
comment=comment, is_read=False, action=cls.MENTION, date=timezone.now()
112-
)
107+
cls.objects.filter(
108+
user__in=tuple(mentions.values()), topic=comment.topic, is_read=True
109+
).update(
110+
comment=comment, is_read=False, action=cls.MENTION, date=timezone.now()
113111
)
114112

115113
@classmethod
@@ -143,14 +141,10 @@ def sync(cls, comment, topic):
143141
topic.comment_set.filter(date__gt=comment.date).order_by("date").first()
144142
)
145143
if next_comment is None:
146-
(
147-
cls.objects.filter(comment=comment, topic=topic).update(
148-
is_read=True, action=cls.UNDEFINED
149-
)
150-
)
151-
return
152-
(
153144
cls.objects.filter(comment=comment, topic=topic).update(
154-
comment=next_comment, action=cls.COMMENT
145+
is_read=True, action=cls.UNDEFINED
155146
)
147+
return
148+
cls.objects.filter(comment=comment, topic=topic).update(
149+
comment=next_comment, action=cls.COMMENT
156150
)

spirit/topic/notification/tests.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,8 @@ def test_topic_notification_ajax_order(self):
275275

276276
TopicNotification.objects.filter(user=self.user).update(is_read=True)
277277
old_date = timezone.now() - datetime.timedelta(days=10)
278-
(
279-
TopicNotification.objects.filter(pk=self.topic_notification.pk).update(
280-
is_read=False, date=old_date
281-
)
278+
TopicNotification.objects.filter(pk=self.topic_notification.pk).update(
279+
is_read=False, date=old_date
282280
)
283281

284282
utils.login(self)
@@ -583,11 +581,7 @@ def test_topic_notification_create_maybe(self):
583581
self.assertEqual(notification.action, COMMENT)
584582

585583
# Creating it again should do nothing
586-
(
587-
TopicNotification.objects.filter(user=user, topic=topic).update(
588-
is_active=False
589-
)
590-
)
584+
TopicNotification.objects.filter(user=user, topic=topic).update(is_active=False)
591585
TopicNotification.create_maybe(user=user, comment=comment)
592586
self.assertFalse(
593587
TopicNotification.objects.get(user=user, topic=topic).is_active
@@ -658,10 +652,8 @@ def test_topic_notification_notify_new_mentions_unactive(self):
658652
set is_read=False when user gets mentioned
659653
even if is_active=False
660654
"""
661-
(
662-
TopicNotification.objects.filter(pk=self.topic_notification.pk).update(
663-
is_active=False
664-
)
655+
TopicNotification.objects.filter(pk=self.topic_notification.pk).update(
656+
is_active=False
665657
)
666658
mentions = {self.user.username: self.user}
667659
comment = utils.create_comment(topic=self.topic_notification.topic)

0 commit comments

Comments
 (0)