-
Notifications
You must be signed in to change notification settings - Fork 55
Celery stubs improvements #210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e3460ff
Add comprehensive celery-stubs type annotations
oliverhaas 60d818d
Add explicit kwargs to Celery.__init__, _task_from_fun, and Signature…
oliverhaas 48e6768
Update celery-stubs from main-ng
oliverhaas 63e7e84
Merge branch 'main' of github.com:sbdchd/celery-types into celery-stu…
oliverhaas fafb7dd
Add explicit keyword-only options to send_task and fix add_periodic_task
oliverhaas d76d7b0
Add explicit keyword-only options to public API methods
oliverhaas 91fe60d
Remove outdated comment about lazy module proxies in __init__.pyi
oliverhaas 3ebca10
Make Celery instance attributes non-optional
oliverhaas 068805f
Make instance attributes non-optional with concise comments
oliverhaas 754854a
Fix Control.inspect return type to type[Inspect]
oliverhaas 5f25d4b
Fix Task.acks_late and acks_on_failure_or_timeout types
oliverhaas d542b42
Fix Control.app, AsyncResult.app, AsyncResult.backend types
oliverhaas fec5e0a
Remove redundant comment about pickling methods in Celery class
oliverhaas c975e54
Remove incorrect celery.app.beat stub
oliverhaas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from typing import Any | ||
|
|
||
| __all__ = ("main",) | ||
|
|
||
| def main() -> Any: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,27 @@ | ||
| from collections.abc import Callable | ||
| from typing import Any | ||
|
|
||
| from celery.app.base import Celery | ||
| from celery.app.task import Task | ||
| from celery.local import Proxy | ||
|
|
||
| current_app: Celery | ||
| current_task: Task[Any, Any] | ||
| __all__ = ( | ||
| "connect_on_app_finalize", | ||
| "current_app", | ||
| "current_task", | ||
| "get_current_app", | ||
| "get_current_task", | ||
| "get_current_worker_task", | ||
| "set_default_app", | ||
| ) | ||
|
|
||
| current_app: Proxy[Celery] | ||
| current_task: Proxy[Task[Any, Any]] | ||
|
|
||
| def get_current_task() -> Task[Any, Any]: ... | ||
| def get_current_app() -> Celery: ... | ||
| def get_current_worker_task() -> Task[Any, Any] | None: ... | ||
| def set_default_app(app: Celery) -> None: ... | ||
| def connect_on_app_finalize( | ||
| callback: Callable[[Celery], Any], | ||
| ) -> Callable[[Celery], Any]: ... | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,158 @@ | ||
| class AMQP: ... | ||
| from datetime import datetime | ||
| from typing import Any, NamedTuple, TypeAlias | ||
|
|
||
| import kombu | ||
| import kombu.pools | ||
| from celery.app.base import Celery | ||
| from celery.app.routes import Router as RouterClass | ||
| from kombu.transport.base import StdChannel | ||
|
|
||
| __all__ = ("AMQP", "Queues", "task_message") | ||
|
|
||
| class task_message(NamedTuple): | ||
| headers: dict[str, Any] | ||
| properties: dict[str, Any] | ||
| body: tuple[Any, ...] | ||
| sent_event: dict[str, Any] | None | ||
|
|
||
| class Queues(dict[str, kombu.Queue]): | ||
| def __init__( | ||
| self, | ||
| queues: list[kombu.Queue] | dict[str, kombu.Queue] | None = None, | ||
| default_exchange: kombu.Exchange | None = None, | ||
| create_missing: bool = True, | ||
| create_missing_queue_type: str | None = None, | ||
| create_missing_queue_exchange_type: str | None = None, | ||
| autoexchange: kombu.Exchange | None = None, | ||
| max_priority: int | None = None, | ||
| default_routing_key: str | None = None, | ||
| ) -> None: ... | ||
| def __missing__(self, name: str) -> kombu.Queue: ... | ||
| def add(self, queue: kombu.Queue, **kwargs: Any) -> None: ... | ||
| def add_compat(self, name: str, **options: Any) -> kombu.Queue: ... | ||
| @property | ||
| def consume_from(self) -> dict[str, kombu.Queue]: ... | ||
| def deselect(self, exclude: list[str]) -> None: ... | ||
| def format(self, indent: int = 0, indent_first: bool = True) -> str: ... | ||
| def new_missing(self, name: str) -> kombu.Queue: ... | ||
| def select(self, include: list[str]) -> None: ... | ||
| def select_add(self, queue: kombu.Queue, **kwargs: Any) -> None: ... | ||
|
|
||
| # Type alias to avoid conflict with AMQP.Queues method | ||
| _Queues: TypeAlias = Queues | ||
|
|
||
| class AMQP: | ||
| # Class attributes | ||
| BrokerConnection: type[kombu.Connection] | ||
| Connection: type[kombu.Connection] | ||
| Consumer: type[kombu.Consumer] | ||
| Producer: type[kombu.Producer] | ||
| queues_cls: type[_Queues] | ||
| argsrepr_maxsize: int | ||
| kwargsrepr_maxsize: int | ||
| autoexchange: kombu.Exchange | None | ||
|
|
||
| app: Celery | ||
|
|
||
| def __init__(self, app: Celery) -> None: ... | ||
| def TaskConsumer( | ||
| self, | ||
| channel: StdChannel, | ||
| queues: list[kombu.Queue] | None = None, | ||
| accept: list[str] | None = None, | ||
| **kw: Any, | ||
| ) -> kombu.Consumer: ... | ||
| def Queues( | ||
| self, | ||
| queues: list[kombu.Queue] | dict[str, kombu.Queue], | ||
| create_missing: bool | None = None, | ||
| create_missing_queue_type: str | None = None, | ||
| create_missing_queue_exchange_type: str | None = None, | ||
| autoexchange: kombu.Exchange | None = None, | ||
| max_priority: int | None = None, | ||
| ) -> _Queues: ... | ||
| def Router( | ||
| self, | ||
| queues: _Queues | None = None, | ||
| create_missing: bool | None = None, | ||
| ) -> RouterClass: ... | ||
| def flush_routes(self) -> None: ... | ||
| def as_task_v1( | ||
| self, | ||
| task_id: str, | ||
| name: str, | ||
| args: tuple[Any, ...] | None = None, | ||
| kwargs: dict[str, Any] | None = None, | ||
| countdown: float | None = None, | ||
| eta: datetime | None = None, | ||
| group_id: str | None = None, | ||
| group_index: int | None = None, | ||
| expires: float | datetime | None = None, | ||
| retries: int = 0, | ||
| chord: Any | None = None, | ||
| callbacks: list[Any] | None = None, | ||
| errbacks: list[Any] | None = None, | ||
| reply_to: str | None = None, | ||
| time_limit: int | None = None, | ||
| soft_time_limit: int | None = None, | ||
| create_sent_event: bool = False, | ||
| root_id: str | None = None, | ||
| parent_id: str | None = None, | ||
| shadow: str | None = None, | ||
| now: datetime | None = None, | ||
| timezone: Any | None = None, | ||
| **compat_kwargs: Any, | ||
| ) -> task_message: ... | ||
| def as_task_v2( | ||
| self, | ||
| task_id: str, | ||
| name: str, | ||
| args: tuple[Any, ...] | None = None, | ||
| kwargs: dict[str, Any] | None = None, | ||
| countdown: float | None = None, | ||
| eta: datetime | None = None, | ||
| group_id: str | None = None, | ||
| group_index: int | None = None, | ||
| expires: float | datetime | None = None, | ||
| retries: int = 0, | ||
| chord: Any | None = None, | ||
| callbacks: list[Any] | None = None, | ||
| errbacks: list[Any] | None = None, | ||
| reply_to: str | None = None, | ||
| time_limit: int | None = None, | ||
| soft_time_limit: int | None = None, | ||
| create_sent_event: bool = False, | ||
| root_id: str | None = None, | ||
| parent_id: str | None = None, | ||
| shadow: str | None = None, | ||
| chain: Any | None = None, | ||
| now: datetime | None = None, | ||
| timezone: Any | None = None, | ||
| origin: str | None = None, | ||
| ignore_result: bool = False, | ||
| argsrepr: str | None = None, | ||
| kwargsrepr: str | None = None, | ||
| stamped_headers: list[str] | None = None, | ||
| replaced_task_nesting: int = 0, | ||
| **options: Any, | ||
| ) -> task_message: ... | ||
| @property | ||
| def create_task_message(self) -> Any: ... | ||
| @property | ||
| def default_exchange(self) -> kombu.Exchange: ... | ||
| @property | ||
| def default_queue(self) -> kombu.Queue: ... | ||
| @property | ||
| def producer_pool(self) -> kombu.pools.ProducerPool: ... | ||
| @property | ||
| def publisher_pool(self) -> kombu.pools.ProducerPool: ... | ||
| @property | ||
| def queues(self) -> _Queues: ... | ||
| @property | ||
| def router(self) -> RouterClass: ... | ||
| @property | ||
| def routes(self) -> list[dict[str, Any]]: ... | ||
| @property | ||
| def send_task_message(self) -> Any: ... | ||
| @property | ||
| def utc(self) -> bool: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| from typing import Any | ||
|
|
||
| __all__ = ("MapAnnotation", "prepare", "resolve_all") | ||
|
|
||
| class MapAnnotation: | ||
| def __init__(self, d: dict[str, Any]) -> None: ... | ||
| def annotate(self, task: Any) -> dict[str, Any] | None: ... | ||
| def annotate_any(self) -> dict[str, Any] | None: ... | ||
|
|
||
| def prepare(annotations: Any) -> Any: ... | ||
| def resolve_all(anno: Any, task: Any) -> dict[str, Any]: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| from collections.abc import Callable | ||
| from typing import Any | ||
|
|
||
| def add_autoretry_behaviour(task: Any, **options: Any) -> Callable[..., Any]: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| from typing import Any | ||
|
|
||
| from celery.backends.base import Backend | ||
|
|
||
| __all__ = ("by_name", "by_url") | ||
|
|
||
| BACKEND_ALIASES: dict[str, str] | ||
| UNKNOWN_BACKEND: str | ||
|
|
||
| def by_name( | ||
| backend: str | None = None, | ||
| loader: Any | None = None, | ||
| extension_namespace: str = "celery.result_backends", | ||
| ) -> type[Backend]: ... | ||
| def by_url(backend: str | None = None, loader: Any | None = None) -> type[Backend]: ... |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.