Skip to content

Commit

Permalink
Switch to Sequence as it's contravariant
Browse files Browse the repository at this point in the history
  • Loading branch information
jacopo committed May 24, 2024
1 parent 1f14244 commit 3924e1b
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions postgrestq/task_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
from datetime import datetime

from uuid import uuid4, UUID
from typing import Optional, Tuple, Iterator, Dict, Any, Callable, List
from typing import (
Optional,
Tuple,
Iterator,
Dict,
Any,
Callable,
List,
Sequence,
)

from psycopg import sql, connect

Expand Down Expand Up @@ -332,7 +341,7 @@ def get(self) -> Tuple[
logger.info(f"Got task with id {task_id}")
return task, task_id, self._queue_name

def get_many(self, amount: int) -> List[
def get_many(self, amount: int) -> Sequence[
Tuple[Optional[Dict[str, Any]], Optional[UUID], Optional[str]],
]:
"""Same as get() but retrieves multiple tasks.
Expand Down Expand Up @@ -653,7 +662,13 @@ def prune_completed_tasks(self, before: int) -> None:

def __iter__(
self,
) -> Iterator[Tuple[Optional[Dict[str, Any]], Optional[UUID]]]:
) -> Iterator[
Tuple[
Optional[Dict[str, Any]],
Optional[UUID],
Optional[str]
]
]:
"""Iterate over tasks and mark them as complete.
This allows to easily iterate over the tasks to process them:
Expand Down

0 comments on commit 3924e1b

Please sign in to comment.