{"id":2823,"library":"types-aiobotocore-sqs","title":"Type Annotations for aiobotocore SQS","description":"This library provides comprehensive type annotations (stubs) for `aiobotocore`'s SQS service, enabling static type checking with tools like MyPy. It ensures type safety when interacting with AWS SQS using `aiobotocore`. The current version is 3.4.0, generated with `mypy-boto3-builder 8.12.0`, and it typically releases new versions in lockstep with `aiobotocore` and `boto3` updates.","status":"active","version":"3.4.0","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","aiobotocore","sqs","typing","mypy","type hints","stubs","cloud","async"],"install":[{"cmd":"pip install types-aiobotocore-sqs aiobotocore","lang":"bash","label":"Install with aiobotocore"}],"dependencies":[{"reason":"Provides the actual SQS client functionality; this library only adds type hints.","package":"aiobotocore","optional":false},{"reason":"Required for type hints on Python versions older than 3.11.","package":"typing-extensions","optional":true}],"imports":[{"symbol":"SQSClient","correct":"from types_aiobotocore_sqs.client import SQSClient"},{"symbol":"SendMessageRequestRequestTypeDef","correct":"from types_aiobotocore_sqs.type_defs import SendMessageRequestRequestTypeDef"},{"symbol":"ReceiveMessageResponseTypeDef","correct":"from types_aiobotocore_sqs.type_defs import ReceiveMessageResponseTypeDef"},{"note":"SQSResource is available via `service_resource`, not `client`.","wrong":"from types_aiobotocore_sqs.client import SQSResource","symbol":"SQSResource","correct":"from types_aiobotocore_sqs.service_resource import SQSResource"}],"quickstart":{"code":"import asyncio\nfrom aiobotocore.session import get_session\nfrom types_aiobotocore_sqs.client import SQSClient\nfrom types_aiobotocore_sqs.type_defs import (\n    SendMessageRequestRequestTypeDef,\n    ReceiveMessageResponseTypeDef,\n    CreateQueueResultTypeDef\n)\n\nasync def main():\n    session = get_session()\n    async with session.create_client(\"sqs\") as client:\n        # Explicitly type hint the client for static analysis\n        sqs_client: SQSClient = client\n\n        queue_name = \"my-test-queue\"\n        queue_url: str = \"\"\n\n        # Create or get queue URL\n        try:\n            create_queue_response: CreateQueueResultTypeDef = await sqs_client.create_queue(\n                QueueName=queue_name,\n                Attributes={'DelaySeconds': '0', 'MessageRetentionPeriod': '345600'}\n            )\n            queue_url = create_queue_response[\"QueueUrl\"]\n            print(f\"Created queue: {queue_url}\")\n        except sqs_client.exceptions.QueueAlreadyExists: # type: ignore - exceptions are dynamic\n            print(f\"Queue '{queue_name}' already exists. Retrieving URL...\")\n            get_queue_response = await sqs_client.get_queue_url(QueueName=queue_name)\n            queue_url = get_queue_response[\"QueueUrl\"]\n\n        # Send a message\n        send_message_params: SendMessageRequestRequestTypeDef = {\n            \"QueueUrl\": queue_url,\n            \"MessageBody\": \"Hello from types-aiobotocore-sqs!\",\n            \"DelaySeconds\": 0,\n        }\n        send_response = await sqs_client.send_message(**send_message_params)\n        print(\"Message sent with ID:\", send_response.get(\"MessageId\"))\n\n        # Receive messages\n        receive_response: ReceiveMessageResponseTypeDef = await sqs_client.receive_message(\n            QueueUrl=queue_url,\n            MaxNumberOfMessages=1,\n            WaitTimeSeconds=1 # Long-polling\n        )\n        messages = receive_response.get(\"Messages\", [])\n        if messages:\n            for message in messages:\n                print(f\"Received message: {message['Body']} (ID: {message['MessageId']})\")\n                # Delete the message after processing\n                await sqs_client.delete_message(\n                    QueueUrl=queue_url,\n                    ReceiptHandle=message[\"ReceiptHandle\"]\n                )\n                print(\"Message deleted.\")\n        else:\n            print(\"No messages received.\")\n\n        # Clean up: delete the queue\n        await sqs_client.delete_queue(QueueUrl=queue_url)\n        print(f\"Deleted queue: {queue_url}\")\n\nif __name__ == \"__main__\":\n    # Ensure AWS credentials are configured (e.g., via ~/.aws/credentials or env vars)\n    # This example requires access to create, send, receive, and delete SQS messages/queues.\n    asyncio.run(main())\n","lang":"python","description":"This quickstart demonstrates how to use `types-aiobotocore-sqs` to add type hints to an `aiobotocore` SQS client. It covers creating a queue, sending a message, receiving and deleting a message, and finally cleaning up the queue. The `SQSClient` object and various TypeDefs are explicitly annotated for enhanced type checking."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer. Ensure your CI/CD pipelines reflect this change.","message":"Python 3.8 support was removed for all `mypy-boto3-builder` generated packages, including `types-aiobotocore-sqs`. Requires Python 3.9 or higher.","severity":"breaking","affected_versions":">=3.4.0 (builder 8.12.0)"},{"fix":"Always install `aiobotocore` alongside `types-aiobotocore-sqs`, typically `pip install aiobotocore types-aiobotocore-sqs`.","message":"`types-aiobotocore-sqs` is a stub-only library. It provides type annotations for `aiobotocore` but does not contain any runtime code. You *must* install `aiobotocore` separately for your application to function.","severity":"gotcha","affected_versions":"all"},{"fix":"Review your imports of specific TypeDefs (`type_defs` module) and adjust names according to the latest package structure. Consult the changelog of `mypy-boto3-builder` for detailed changes.","message":"The `mypy-boto3-builder` (version 8.9.0 and newer) introduced breaking changes in TypeDef naming conventions for some services. For example, `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`. While this library targets `aiobotocore`, similar changes might occur for its generated TypeDefs.","severity":"breaking","affected_versions":">=3.0.0 (builder 8.9.0)"},{"fix":"Verify that your `types-aiobotocore-sqs` version is compatible with your `aiobotocore` version. The `types-aiobotocore-sqs` package typically specifies its `aiobotocore` dependency range.","message":"For optimal type checking, the version of `types-aiobotocore-sqs` should ideally match the major/minor version of your installed `aiobotocore` library to ensure type compatibility with the underlying API.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}