From a2b43e48c0a18ae510efb8ba707cf5ac065cf643 Mon Sep 17 00:00:00 2001 From: Arthur Deierlein Date: Mon, 25 Nov 2024 10:56:42 +0100 Subject: [PATCH] chore(backend): make ruff 0.8.0 happy --- backend/ruff.toml | 1 - backend/timed/employment/models.py | 2 +- .../tests/test_notify_reviewers_unverified.py | 15 +++------------ backend/timed/reports/views.py | 2 +- backend/timed/tracking/views.py | 2 +- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/backend/ruff.toml b/backend/ruff.toml index 82ec1dc49..0b31e19c6 100644 --- a/backend/ruff.toml +++ b/backend/ruff.toml @@ -62,7 +62,6 @@ select = [ "W605", # invalid escape sequence ] ignore = [ - "ANN101", # this is deprecated and annotating self is unnecessary "D203", # we prefer blank-line-before-class (D211) for black compat "D213", # we prefer multi-line-summary-first-line (D212) "COM812", # ignore due to conflict with formatter diff --git a/backend/timed/employment/models.py b/backend/timed/employment/models.py index 9e36759d2..f478ae9d0 100644 --- a/backend/timed/employment/models.py +++ b/backend/timed/employment/models.py @@ -264,7 +264,7 @@ def calculate_worktime( # converting workdays as db expects 1 (Sunday) to 7 (Saturday) workdays_db = [ # special case for Sunday - int(day) == 7 and 1 or int(day) + 1 # noqa: PLR2004 + (int(day) == 7 and 1) or int(day) + 1 # noqa: PLR2004 for day in self.location.workdays ] holidays = PublicHoliday.objects.filter( diff --git a/backend/timed/notifications/tests/test_notify_reviewers_unverified.py b/backend/timed/notifications/tests/test_notify_reviewers_unverified.py index 19f8df48b..d35c31f15 100644 --- a/backend/timed/notifications/tests/test_notify_reviewers_unverified.py +++ b/backend/timed/notifications/tests/test_notify_reviewers_unverified.py @@ -57,10 +57,7 @@ def test_notify_reviewers_with_cc_and_message(mailoutbox, cc, message): assert len(mailoutbox) == 1 mail = mailoutbox[0] assert mail.to == [reviewer_work.email] - url = ( - "http://localhost:4200/analysis?fromDate=2017-07-01&" - "toDate=2017-07-31&reviewer=%d&editable=1" - ) % reviewer_work.id + url = f"http://localhost:4200/analysis?fromDate=2017-07-01&toDate=2017-07-31&reviewer={reviewer_work.id}&editable=1" assert url in mail.body assert message in mail.body assert mail.cc[0] == cc @@ -85,10 +82,7 @@ def test_notify_reviewers(mailoutbox): assert len(mailoutbox) == 1 mail = mailoutbox[0] assert mail.to == [reviewer_work.email] - url = ( - "http://localhost:4200/analysis?fromDate=2017-07-01&" - "toDate=2017-07-31&reviewer=%d&editable=1" - ) % reviewer_work.id + url = f"http://localhost:4200/analysis?fromDate=2017-07-01&toDate=2017-07-31&reviewer={reviewer_work.id}&editable=1" assert url in mail.body assert Notification.objects.count() == 1 @@ -118,8 +112,5 @@ def test_notify_reviewers_reviewer_hierarchy(mailoutbox): assert len(mailoutbox) == 1 mail = mailoutbox[0] assert mail.to == [task_reviewer.email] - url = ( - "http://localhost:4200/analysis?fromDate=2017-07-01&" - "toDate=2017-07-31&reviewer=%d&editable=1" - ) % task_reviewer.id + url = f"http://localhost:4200/analysis?fromDate=2017-07-01&toDate=2017-07-31&reviewer={task_reviewer.id}&editable=1" assert url in mail.body diff --git a/backend/timed/reports/views.py b/backend/timed/reports/views.py index 8835c5fad..1821b9cb3 100644 --- a/backend/timed/reports/views.py +++ b/backend/timed/reports/views.py @@ -28,7 +28,7 @@ from . import filters if TYPE_CHECKING: - from typing import Iterable + from collections.abc import Iterable from ezodf.document import FlatXMLDocument, PackagedDocument diff --git a/backend/timed/tracking/views.py b/backend/timed/tracking/views.py index a2febc39e..c6ce664e6 100644 --- a/backend/timed/tracking/views.py +++ b/backend/timed/tracking/views.py @@ -249,7 +249,7 @@ def bulk(self, request): _("Reviewer filter needs to be set to verifying user") ) - fields["verified_by"] = verified and user or None + fields["verified_by"] = (verified and user) or None if fields.get("review") or any(queryset.values_list("review", flat=True)): raise exceptions.ParseError(