{"id":6560,"library":"celery-stubs","title":"Celery Stubs","description":"celery-stubs provides type hints for the popular Celery distributed task queue, allowing static type checkers like MyPy to validate Celery-related code. This package is currently at version 0.1.3, released in February 2023, and exhibits a slow, infrequent release cadence.","status":"maintenance","version":"0.1.3","language":"en","source_language":"en","source_url":"https://github.com/ryanwang520/celery-stubs","tags":["type-stubs","celery","mypy","type-hinting"],"install":[{"cmd":"pip install celery-stubs","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"celery-stubs provides type hints for the 'celery' library itself. You import from 'celery', and the type checker uses the stubs.","symbol":"Celery","correct":"from celery import Celery"},{"note":"celery-stubs provides type hints for the 'celery' library itself. You import from 'celery', and the type checker uses the stubs.","symbol":"Task","correct":"from celery import Task"}],"quickstart":{"code":"import os\nfrom celery import Celery\nfrom typing import Dict, Any\n\n# Configure Celery (replace with your actual broker/backend if running)\napp = Celery(\n    'my_app',\n    broker=os.environ.get('CELERY_BROKER_URL', 'redis://localhost:6379/0'),\n    backend=os.environ.get('CELERY_RESULT_BACKEND', 'redis://localhost:6379/0')\n)\n\n@app.task\ndef add(x: int, y: int) -> int:\n    return x + y\n\n@app.task\ndef process_data(data: Dict[str, Any]) -> None:\n    print(f\"Processing: {data['value']}\")\n\n# To demonstrate type checking, you would typically run mypy:\n# mypy your_script_name.py\n# If celery-stubs is installed, mypy will use it to validate types\n# related to Celery objects (e.g., app.task decorator, AsyncResult, etc.)\n\n# Example of type-hinted usage (not directly runnable without a Celery worker):\nif __name__ == \"__main__\":\n    result = add.delay(1, 2)\n    print(f\"Task ID: {result.id}\")\n    # result_value: int = result.get() # This line would be type-checked by mypy\n\n    # Example of incorrect usage that mypy would catch with stubs:\n    # bad_result = add.delay('a', 'b') # mypy would flag this as type error","lang":"python","description":"This quickstart demonstrates a basic Celery application using type hints. With `celery-stubs` installed, a static type checker like MyPy can validate the type annotations within your Celery tasks and interactions with Celery objects, helping catch type-related errors before runtime."},"warnings":[{"fix":"Understand that `celery-stubs` is a development dependency for type checking, not a runtime dependency.","message":"This package provides *only* type stubs (`.pyi` files) for static analysis and does not add any runtime functionality or client-side proxy behavior to Celery. It is purely for enhancing type checking capabilities.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Pin the version of `celery-stubs` in your project's dependencies to prevent unexpected breaking changes, e.g., `celery-stubs==0.1.3`.","message":"The `celery-stubs` package is currently in '3 - Alpha' development status. This indicates that its API might not be stable, and future minor versions could introduce breaking changes.","severity":"gotcha","affected_versions":"All versions (0.1.x)"},{"fix":"Evaluate `celery-types` (`pip install celery-types`) as a potential alternative if `celery-stubs` does not meet your type-hinting needs for the full Celery ecosystem.","message":"For more comprehensive and actively maintained type stubs covering the broader Celery ecosystem (including `amqp`, `kombu`, `billiard`, etc.), consider using the `celery-types` package by `sbdchd` instead. It appears to be more actively developed and widely used.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}