Skip to content

Commit

Permalink
Add missing types for GroupResult model of django-celery-results modu…
Browse files Browse the repository at this point in the history
…le (#82)
  • Loading branch information
desecho committed Jun 11, 2022
1 parent b50ce77 commit ed60ef3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
13 changes: 12 additions & 1 deletion django_celery_results-stubs/managers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from uuid import UUID

from django.db import models
from django.db.models.query import QuerySet
from django_celery_results.models import TaskResult
from django_celery_results.models import GroupResult, TaskResult

class TaskResultManager(models.Manager[TaskResult]):
def get_task(self, task_id: str) -> TaskResult: ...
Expand All @@ -24,3 +24,14 @@ class TaskResultManager(models.Manager[TaskResult]):
) -> TaskResult: ...
def get_all_expired(self, expires: timedelta) -> QuerySet[TaskResult]: ...
def delete_expired(self, expires: timedelta) -> None: ...

class GroupResultManager(models.Manager[GroupResult]):
def get_group(self, group_id: str) -> GroupResult: ...
def store_group_result(
self,
content_type: str,
content_encoding: str,
group_id: str,
result: Optional[str],
using: Optional[str] = ...,
) -> GroupResult: ...
17 changes: 16 additions & 1 deletion django_celery_results-stubs/models.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from datetime import datetime
from typing import List, Optional, Tuple

from django.db import models
from django_celery_results.managers import TaskResultManager
from django_celery_results.managers import GroupResultManager, TaskResultManager
from typing_extensions import TypedDict

ALL_STATES: List[str]
Expand Down Expand Up @@ -34,3 +34,18 @@ class TaskResult(models.Model):
meta: models.TextField[Optional[str]]
objects: TaskResultManager
def as_dict(self) -> TaskResultDict: ...

class GroupResultDict(TypedDict):
group_id: str
result: Optional[str]
date_done: datetime

class GroupResult(models.Model):
group_id: models.CharField[str]
date_created: models.DateTimeField[datetime]
date_done: models.DateTimeField[datetime]
content_type: models.CharField[str]
content_encoding: models.CharField[str]
result: models.TextField[Optional[str]]
objects: GroupResultManager
def as_dict(self) -> GroupResultDict: ...

0 comments on commit ed60ef3

Please sign in to comment.