Skip to content

Commit

Permalink
Add misc missing types (#163)
Browse files Browse the repository at this point in the history
This PR adds a few missing types:
* `ColorFormatter`
* `get_current_task`

and it fixes the definition of `Context.headers` to be a dict (mutable)
  • Loading branch information
youtux authored Sep 2, 2024
1 parent 1179751 commit 35e87e9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions celery-stubs/_state.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ from celery.app.task import Task

current_app: Celery
current_task: Task[Any, Any]

def get_current_task() -> Task[Any, Any]: ...
2 changes: 1 addition & 1 deletion celery-stubs/app/task.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Context:
expires: int | None
group: str | None
group_index: int | None
headers: Mapping[str, Any] | None
headers: dict[str, Any] | None
hostname: str | None
id: str | None
ignore_result: bool
Expand Down
12 changes: 11 additions & 1 deletion celery-stubs/utils/log.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from logging import Logger
from logging import Formatter, Logger
from typing import ClassVar

from celery.utils.term import colored

class LoggingProxy: ...

Expand All @@ -7,3 +10,10 @@ def get_task_logger(name: str) -> Logger: ...

task_logger: Logger
worker_logger: Logger

class ColorFormatter(Formatter):
use_color: bool

COLORS: ClassVar[dict[str, colored]]
colors: ClassVar[dict[str, colored]]
def __init__(self, fmt: str | None = ..., use_color: bool = ...) -> None: ...

0 comments on commit 35e87e9

Please sign in to comment.