Skip to content

Commit

Permalink
always use type Protocol Serializer instead of DefaultSerializer
Browse files Browse the repository at this point in the history
  • Loading branch information
terencehonles committed Nov 1, 2024
1 parent 740b518 commit 42b4757
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions rq/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
import sys
import warnings
from typing import List, Type
from typing import cast, List, Type, TYPE_CHECKING

import click
from redis.exceptions import ConnectionError
Expand Down Expand Up @@ -48,6 +48,9 @@
from rq.worker_pool import WorkerPool
from rq.worker_registration import clean_worker_registry

if TYPE_CHECKING:
from rq.serializers import Serializer


@click.group()
@click.version_option(version)
Expand Down Expand Up @@ -461,7 +464,7 @@ def worker_pool(
setup_loghandlers_from_args(verbose, quiet, date_format, log_format)

if serializer:
serializer_class: Type[DefaultSerializer] = import_attribute(serializer) # type: ignore[assignment]
serializer_class = cast(Type['Serializer'], import_attribute(serializer))
else:
serializer_class = DefaultSerializer

Expand Down
4 changes: 2 additions & 2 deletions rq/worker_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(
self._sleep: int = 0
self.status: self.Status = self.Status.IDLE # type: ignore
self.worker_class: Type[BaseWorker] = worker_class
self.serializer: Type[DefaultSerializer] = serializer
self.serializer: Type['Serializer'] = serializer
self.job_class: Type[Job] = job_class

# A dictionary of WorkerData keyed by worker name
Expand Down Expand Up @@ -247,7 +247,7 @@ def run_worker(
connection_pool_class,
connection_pool_kwargs: dict,
worker_class: Type[BaseWorker] = Worker,
serializer: Type[DefaultSerializer] = DefaultSerializer,
serializer: Type['Serializer'] = DefaultSerializer,
job_class: Type[Job] = Job,
burst: bool = True,
logging_level: str = "INFO",
Expand Down

0 comments on commit 42b4757

Please sign in to comment.