Skip to content

Commit faebef8

Browse files
committed
Update ruff config
1 parent f5eba33 commit faebef8

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

django_tasks/backends/database/management/commands/db_worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def run(self) -> None:
9494

9595
if self.startup_delay and self.interval:
9696
# Add a random small delay before starting to avoid a thundering herd
97-
time.sleep(random.random())
97+
time.sleep(random.random()) # noqa: S311
9898

9999
while self.running:
100100
tasks = DBTaskResult.objects.ready().filter(backend_name=self.backend_name)

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@ rq = [
6969
]
7070

7171
[tool.ruff.lint]
72-
select = ["E", "F", "I", "W", "N", "B", "A", "C4", "T20", "DJ"]
72+
select = ["E", "F", "I", "W", "N", "B", "A", "C4", "T20", "DJ", "S", "UP"]
7373
ignore = ["E501", "DJ008"]
7474

7575
[tool.ruff.lint.per-file-ignores]
7676
"tests/db_worker_test_settings.py" = ["F403", "F405"]
7777
"tests/settings_fast.py" = ["F403", "F405"]
78+
"tests/**.py" = ["S101", "S603", "S105"]
7879

7980
[tool.mypy]
8081
plugins = ["mypy_django_plugin.main"]

tests/tests/test_database_backend.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
import uuid
1010
import warnings
1111
from collections import Counter
12+
from collections.abc import Sequence
1213
from contextlib import redirect_stderr
1314
from datetime import datetime, timedelta
1415
from functools import partial
1516
from io import StringIO
16-
from typing import Any, List, Optional, Sequence, Union, cast
17+
from typing import Any, cast
1718
from unittest import mock, skipIf
1819

1920
import django
@@ -944,7 +945,7 @@ def test_context(self) -> None:
944945
}
945946
)
946947
class DatabaseTaskResultTestCase(TransactionTestCase):
947-
def execute_in_new_connection(self, sql: Union[str, QuerySet]) -> Sequence:
948+
def execute_in_new_connection(self, sql: str | QuerySet) -> Sequence:
948949
if isinstance(sql, QuerySet):
949950
sql = str(sql.query)
950951
new_connection = connections.create_connection("default")
@@ -1423,7 +1424,7 @@ class DatabaseWorkerProcessTestCase(TransactionTestCase):
14231424
WORKER_STARTUP_TIME = 1
14241425

14251426
def setUp(self) -> None:
1426-
self.processes: List[subprocess.Popen] = []
1427+
self.processes: list[subprocess.Popen] = []
14271428

14281429
def tearDown(self) -> None:
14291430
# Try n times to kill any remaining child processes
@@ -1437,10 +1438,10 @@ def tearDown(self) -> None:
14371438

14381439
def start_worker(
14391440
self,
1440-
args: Optional[List[str]] = None,
1441+
args: list[str] | None = None,
14411442
*,
14421443
debug: bool = False,
1443-
worker_id: Optional[str] = None,
1444+
worker_id: str | None = None,
14441445
) -> subprocess.Popen:
14451446
if args is None:
14461447
args = []

tests/tests/test_rq_backend.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
22
import os
33
import uuid
4-
from typing import Union, cast
4+
from typing import cast
55
from unittest.mock import patch
66

77
import django_rq
@@ -25,9 +25,7 @@
2525
# Set up the connection before RQ Django reads the settings.
2626
# The connection must be the same because in fakeredis connections
2727
# do not share the state. Therefore, we define a singleton object to reuse it.
28-
def get_fake_connection(
29-
config: dict, strict: bool
30-
) -> Union[FakeRedis, FakeStrictRedis]:
28+
def get_fake_connection(config: dict, strict: bool) -> FakeRedis | FakeStrictRedis:
3129
redis_cls = FakeStrictRedis if strict else FakeRedis
3230
if "URL" in config:
3331
return redis_cls.from_url(

0 commit comments

Comments
 (0)