{"id":8417,"library":"pika-stubs","title":"pika-stubs","description":"Pika-stubs provides PEP-484 compliant type stubs and a Mypy plugin for the Pika RabbitMQ client library. Its purpose is to offer more precise static type checking and improved type inference for code written with Pika. The current version is 0.1.3, released in June 2020. The project appears to be in an unmaintained or abandoned state, classified as '1 - Planning' on PyPI with no subsequent releases.","status":"abandoned","version":"0.1.3","language":"en","source_language":"en","source_url":"https://github.com/hahow/pika-stubs","tags":["typing","mypy","stubs","pika","rabbitmq","amqp"],"install":[{"cmd":"pip install pika-stubs","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Provides type stubs for the pika library; essential for its functionality.","package":"pika","optional":false},{"reason":"A static type checker that utilizes these stubs for type inference.","package":"mypy","optional":false}],"imports":[{"note":"Pika-stubs provides types for the `pika` library; you import from `pika`, not `pika-stubs`.","symbol":"BlockingConnection","correct":"import pika\n# Or from pika import BlockingConnection"},{"note":"Type stubs enhance existing Pika imports; direct imports from pika-stubs are not typical.","symbol":"BasicProperties","correct":"from pika.spec import BasicProperties"}],"quickstart":{"code":"# consumer.py\nimport pika\nimport os\n\ndef callback(ch: pika.channel.Channel, method: pika.spec.Basic.Deliver, properties: pika.spec.BasicProperties, body: bytes) -> None:\n    print(f\" [x] Received {body.decode()}\")\n\ndef main() -> None:\n    rabbitmq_host = os.environ.get('RABBITMQ_HOST', 'localhost')\n    connection = pika.BlockingConnection(\n        pika.ConnectionParameters(host=rabbitmq_host)\n    )\n    channel = connection.channel()\n\n    channel.queue_declare(queue='hello')\n\n    channel.basic_consume(queue='hello', on_message_callback=callback, auto_ack=True)\n\n    print(' [*] Waiting for messages. To exit press CTRL+C')\n    try:\n        channel.start_consuming()\n    except KeyboardInterrupt:\n        channel.stop_consuming()\n    finally:\n        connection.close()\n\nif __name__ == '__main__':\n    main()\n\n# To run mypy with pika-stubs:\n# 1. pip install pika pika-stubs mypy\n# 2. RABBITMQ_HOST=localhost python consumer.py (in one terminal)\n# 3. mypy consumer.py (in another terminal)","lang":"python","description":"This quickstart demonstrates how pika-stubs enhances type checking for a basic Pika consumer. After installing `pika-stubs` alongside `pika` and `mypy`, running `mypy` on the Python file will utilize the provided type information to catch potential errors or provide better IDE suggestions. The example uses environment variables for RabbitMQ host for flexibility."},"warnings":[{"fix":"Ensure your Python environment is 3.8 or newer before installing `pika-stubs`. Consider using a virtual environment.","message":"Pika-stubs requires Python 3.8 or newer. Attempting to install on older Python versions (e.g., 3.7) will result in an installation failure.","severity":"breaking","affected_versions":"<=0.1.3 on Python <3.8"},{"fix":"For newer Pika versions or more active maintenance, consider `pip install types-pika-ts` or `pip install types-pika` instead. Consult their respective documentation for usage.","message":"This library (pika-stubs) appears to be unmaintained. Its last release was in June 2020, and its PyPI status is '1 - Planning'. More actively maintained alternatives like `types-pika-ts` (part of typeshed) or `types-pika` may offer more up-to-date and complete typings for recent Pika versions.","severity":"gotcha","affected_versions":"All versions of pika-stubs (0.1.3)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Upgrade your Python environment to version 3.8 or newer. For example, `pyenv install 3.9.18` and `pyenv local 3.9.18` or `python3.9 -m pip install pika-stubs`.","cause":"The Python version being used is older than the minimum requirement (Python 3.8) for `pika-stubs`.","error":"ERROR: Could not find a version that satisfies the requirement pika-stubs (from versions: none)\nERROR: No matching distribution found for pika-stubs"},{"fix":"Ensure both `pika` and `pika-stubs` are installed in the same environment as Mypy: `pip install pika pika-stubs`. If using a custom `mypy.ini` or setup, verify `mypy_path` or `plugins` configuration.","cause":"Either the `pika` library itself or the `pika-stubs` package is not installed, or Mypy is not configured to find them.","error":"mypy: `pika` is not installed, or mypy could not find stubs for it. Please install `pika` or `pika-stubs`."}]}