{"id":3839,"library":"types-boto3-sqs","title":"Type Annotations for boto3 SQS","description":"This library provides PEP 561-compliant type annotations for the boto3 SQS service, generated by `mypy-boto3-builder`. It enhances development with static type checking for AWS SQS operations using boto3. The current version is 1.42.3, and it follows a frequent release cadence, typically aligning with boto3 updates and `mypy-boto3-builder` improvements.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","aws","sqs","types","mypy","type-hints","static-analysis"],"install":[{"cmd":"pip install types-boto3-sqs","lang":"bash","label":"Install types-boto3-sqs"}],"dependencies":[{"reason":"Required at runtime to use the SQS client with these type annotations.","package":"boto3","optional":false}],"imports":[{"note":"Legacy import paths starting with 'mypy_boto3_' were moved to a separate product in `mypy-boto3-builder` version 8.9.0 and are no longer generated with the standard `types-boto3-*` packages.","wrong":"from mypy_boto3_sqs import SQSClient","symbol":"SQSClient","correct":"from types_boto3_sqs import SQSClient"},{"note":"Type definitions for SQS response objects are found in the `type_defs` submodule.","symbol":"MessageTypeDef","correct":"from types_boto3_sqs.type_defs import MessageTypeDef"}],"quickstart":{"code":"import boto3\nimport os\n\nfrom types_boto3_sqs import SQSClient\nfrom types_boto3_sqs.type_defs import SendMessageResultTypeDef, MessageTypeDef\n\ndef get_sqs_client() -> SQSClient:\n    # In a real application, AWS credentials and region would be configured\n    # via environment variables, ~/.aws/credentials, or IAM roles.\n    # Using placeholder for demonstration.\n    session = boto3.Session(\n        aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY'),\n        aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET'),\n        region_name=os.environ.get('AWS_REGION', 'us-east-1')\n    )\n    return session.client('sqs')\n\ndef send_and_receive_message(queue_url: str) -> None:\n    client: SQSClient = get_sqs_client()\n\n    # Send a message\n    send_response: SendMessageResultTypeDef = client.send_message(\n        QueueUrl=queue_url,\n        MessageBody='Hello SQS with types!'\n    )\n    print(f\"Message sent with ID: {send_response.get('MessageId')}\")\n\n    # Receive messages\n    receive_response = client.receive_message(\n        QueueUrl=queue_url,\n        MaxNumberOfMessages=1,\n        WaitTimeSeconds=5\n    )\n\n    messages: list[MessageTypeDef] = receive_response.get('Messages', [])\n    if messages:\n        for message in messages:\n            print(f\"Received message: {message.get('Body')}\")\n            # For production, remember to delete the message after processing\n            # client.delete_message(QueueUrl=queue_url, ReceiptHandle=message['ReceiptHandle'])\n    else:\n        print(\"No messages received.\")\n\n# Example usage (replace with your actual SQS queue URL)\n# queue_url = os.environ.get('SQS_QUEUE_URL', 'https://sqs.us-east-1.amazonaws.com/123456789012/my-test-queue')\n# if 'DUMMY' not in os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY'):\n#     send_and_receive_message(queue_url)\n# else:\n#     print(\"Skipping SQS operations: AWS credentials not configured. Set AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and SQS_QUEUE_URL.\")","lang":"python","description":"This quickstart demonstrates how to initialize an SQS client with `boto3` and use the provided type annotations (`SQSClient`, `SendMessageResultTypeDef`, `MessageTypeDef`) for `send_message` and `receive_message` operations. Type checkers like MyPy will use these annotations to validate your code."},"warnings":[{"fix":"Upgrade Python to 3.9 or newer, or pin `types-boto3-sqs<1.42.0`.","message":"Python 3.8 support was removed from `mypy-boto3-builder` (and consequently, from `types-boto3-*` packages) starting with version 8.12.0. Users on Python 3.8 should use older versions of `types-boto3-sqs` or upgrade their Python interpreter.","severity":"breaking","affected_versions":">=8.12.0 of mypy-boto3-builder (equivalent types-boto3-sqs >=1.42.0)"},{"fix":"Update your code to use the new TypeDef names. Consult the `mypy-boto3-builder` documentation or regenerate your stub references.","message":"In `mypy-boto3-builder` version 8.9.0, there were breaking changes to TypeDef naming conventions. Specifically, TypeDefs for packed method arguments use shorter names where possible (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`), and conflicting `Extra` postfixes were moved (e.g., `CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`). If you explicitly imported these TypeDefs, your code may break.","severity":"breaking","affected_versions":">=8.9.0 of mypy-boto3-builder (equivalent types-boto3-sqs >=1.28.0)"},{"fix":"Ensure your `boto3` and `types-boto3-sqs` package versions are as closely aligned as possible, ideally using the same major and minor versions.","message":"The `types-boto3-sqs` package is specifically built for a corresponding `boto3` version (e.g., `types-boto3-sqs` 1.42.3 for `boto3` 1.42.3). While minor mismatches might work, significant version discrepancies between `boto3` and `types-boto3-sqs` can lead to inaccurate type hints or type-checking errors, as the underlying AWS API might have changed.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}