Skip to content

Commit ddece64

Browse files
committed
refactor
1 parent 834f780 commit ddece64

File tree

7 files changed

+15
-17
lines changed

7 files changed

+15
-17
lines changed

.github/actions/test-coverage/action.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,5 @@ runs:
4545
${{ env.REPORT }}
4646
```
4747
repo-token: ${{ inputs.repoToken }}
48-
repo-token-user-login: 'github-actions[bot]'
4948
allow-repeats: true
5049
update-only: true

scheduler/management/commands/import.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def create_job_from_dict(job_dict: Dict[str, Any], update):
3838
target = timezone.make_naive(target)
3939
kwargs["scheduled_time"] = target
4040
model_fields = set(map(lambda field: field.attname, model._meta.get_fields()))
41-
keys_to_ignore = list(filter(lambda k: k not in model_fields, kwargs.keys()))
41+
keys_to_ignore = list(filter(lambda _k: _k not in model_fields, kwargs.keys()))
4242
for k in keys_to_ignore:
4343
del kwargs[k]
4444
scheduled_job = model.objects.create(**kwargs)

scheduler/management/commands/rqstats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def _print_stats_dashboard(self, statistics, prev_stats=None):
6868
# Deal with colors
6969
if prev_stats and len(prev_stats["queues"]) > ind:
7070
prev = prev_stats["queues"][ind]
71-
prev_vals = (prev[k] for k in KEYS)
71+
prev_vals = tuple(prev[k] for k in KEYS)
7272
colors = [
7373
ANSI_LIGHT_GREEN if vals[i] != prev_vals[i] else ANSI_LIGHT_WHITE for i in range(len(prev_vals))
7474
]

scheduler/models/scheduled_task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def __str__(self):
317317
def save(self, **kwargs):
318318
schedule_job = kwargs.pop("schedule_job", True)
319319
update_fields = kwargs.get("update_fields", None)
320-
if update_fields:
320+
if update_fields is not None:
321321
kwargs["update_fields"] = set(update_fields).union({"modified"})
322322
super(BaseTask, self).save(**kwargs)
323323
if schedule_job:

scheduler/queues.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, Dict
1+
from typing import List, Dict, Set
22

33
import redis
44
import valkey
@@ -87,7 +87,7 @@ def get_connection(queue_settings, use_strict_redis=False):
8787

8888

8989
def get_queue(
90-
name="default", default_timeout=None, is_async=None, autocommit=None, connection=None, **kwargs
90+
name="default", default_timeout=None, is_async=None, autocommit=None, connection=None, **kwargs
9191
) -> DjangoQueue:
9292
"""Returns an DjangoQueue using parameters defined in `SCHEDULER_QUEUES`"""
9393
from .settings import QUEUES
@@ -107,18 +107,18 @@ def get_queue(
107107
)
108108

109109

110-
def get_all_workers():
110+
def get_all_workers() -> Set[DjangoWorker]:
111111
from .settings import QUEUES
112112

113-
workers = set()
113+
workers_set: Set[DjangoWorker] = set()
114114
for queue_name in QUEUES:
115115
connection = get_connection(QUEUES[queue_name])
116116
try:
117-
curr_workers = set(DjangoWorker.all(connection=connection))
118-
workers.update(curr_workers)
117+
curr_workers: Set[DjangoWorker] = set(DjangoWorker.all(connection=connection))
118+
workers_set.update(curr_workers)
119119
except (redis.ConnectionError, valkey.ConnectionError) as e:
120120
logger.error(f"Could not connect for queue {queue_name}: {e}")
121-
return workers
121+
return workers_set
122122

123123

124124
def _queues_share_connection_params(q1_params: Dict, q2_params: Dict):

scheduler/rq_classes.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ def register_sentry(sentry_dsn, **opts):
3838

3939

4040
def as_str(v: Union[bytes, str]) -> Optional[str]:
41-
"""Converts a bytes value to a string using `utf-8`.
41+
"""Converts a `bytes` value to a string using `utf-8`.
4242
4343
:param v: The value (None/bytes/str)
44-
:raises: ValueError: If the value is not bytes or string
44+
:raises: ValueError: If the value is not `bytes` or `str`
4545
:returns: Either the decoded string or None
4646
"""
4747
if v is None:
@@ -101,10 +101,9 @@ def _start_scheduler(
101101
This is specifically designed to be run by the worker when running the `work()` method.
102102
Instantiates the DjangoScheduler and tries to acquire a lock.
103103
If the lock is acquired, start scheduler.
104-
If worker is on burst mode just enqueues scheduled jobs and quits,
104+
If the worker is on burst mode, just enqueues scheduled jobs and quits,
105105
otherwise, starts the scheduler in a separate process.
106106
107-
108107
:param burst (bool, optional): Whether to work on burst mode. Defaults to False.
109108
:param logging_level (str, optional): Logging level to use. Defaults to "INFO".
110109
:param date_format (str, optional): Date Format. Defaults to DEFAULT_LOGGING_DATE_FORMAT.

scheduler/templates/admin/scheduler/jobs.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<th scope="col" class="action-checkbox-column">
5555
<div class="text">
5656
<span><input type="checkbox" id="action-toggle"
57-
style="display: inline-block;"></span>
57+
style="display: inline-block;"/></span>
5858
</div>
5959
<div class="clear"></div>
6060
</th>
@@ -92,7 +92,7 @@
9292
<td class="action-checkbox">
9393
<input class="action-select"
9494
name="_selected_action" type="checkbox"
95-
value="{{ job.id }}">
95+
value="{{ job.id }}" />
9696
</td>
9797
<th>
9898
<a href="{% url 'job_details' job.id %}">

0 commit comments

Comments
 (0)