Examples
Auto-generated documentation for SQS type annotations stubs module types-aiobotocore-sqs.
Client
Implicit type annotations
Can be used with types-aioboto3[sqs]
package installed.
Write your SQS
code as usual,
type checking and code completion should work out of the box.
from aioboto3.session import Session
session = Session()
async with session.client("sqs") as client: # (1)
result = await client.add_permission() # (2)
- client: SQSClient
- result: EmptyResponseMetadataTypeDef
from aioboto3.session import Session
session = Session()
async with session.client("sqs") as client: # (1)
paginator = client.get_paginator("list_dead_letter_source_queues") # (2)
async for item in paginator.paginate(...):
print(item) # (3)
- client: SQSClient
- paginator: ListDeadLetterSourceQueuesPaginator
- item: ListDeadLetterSourceQueuesResultTypeDef
Explicit type annotations
With types-aioboto3-lite[sqs]
or a standalone types_aiobotocore_sqs
package, you have to explicitly specify
client: SQSClient
type annotation.
All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.
from aioboto3.session import Session
from types_aiobotocore_sqs.client import SQSClient
from types_aiobotocore_sqs.type_defs import EmptyResponseMetadataTypeDef
from types_aiobotocore_sqs.type_defs import AddPermissionRequestRequestTypeDef
session = Session()
client: SQSClient
async with session.client("sqs") as client: # (1)
kwargs: AddPermissionRequestRequestTypeDef = {...} # (2)
result: EmptyResponseMetadataTypeDef = await client.add_permission(**kwargs) # (3)
- client: SQSClient
- kwargs: AddPermissionRequestRequestTypeDef
- result: EmptyResponseMetadataTypeDef
from aioboto3.session import Session
from types_aiobotocore_sqs.client import SQSClient
from types_aiobotocore_sqs.paginator import ListDeadLetterSourceQueuesPaginator
from types_aiobotocore_sqs.type_defs import ListDeadLetterSourceQueuesResultTypeDef
session = Session()
client: SQSClient
async with session.client("sqs") as client: # (1)
paginator: ListDeadLetterSourceQueuesPaginator = client.get_paginator("list_dead_letter_source_queues") # (2)
async for item in paginator.paginate(...):
item: ListDeadLetterSourceQueuesResultTypeDef
print(item) # (3)
- client: SQSClient
- paginator: ListDeadLetterSourceQueuesPaginator
- item: ListDeadLetterSourceQueuesResultTypeDef
Service Resource
Implicit type annotations
Can be used with types-aioboto3[sqs]
package installed.
from aioboto3.session import Session
session = Session()
async with session.resource("sqs") as resource: # (1)
result = resource.Message() # (2)
- resource: SQSServiceResource
- result:
from aioboto3.session import Session
session = Session()
resource = session.resource("sqs") # (1)
collection = resource.queues # (2)
for item in collection:
print(item) # (3)
- resource: SQSServiceResource
- collection: SQSServiceResource
- item: Queue
Explicit type annotations
With types-aioboto3-lite[sqs]
or a standalone types_aiobotocore_sqs
package, you have to explicitly specify
resource: SQSServiceResource
type annotation.
All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.
from aioboto3.session import Session
from types_aiobotocore_sqs.service_resource import SQSServiceResource
from types_aiobotocore_sqs.service_resource import Message
session = Session()
resource: SQSServiceResource
async with session.resource("sqs") as resource: # (1)
result: Message = resource.Message() # (2)
- resource: SQSServiceResource
- result:
from aioboto3.session import Session
from types_aiobotocore_sqs.service_resource import SQSServiceResource
from types_aiobotocore_sqs.service_resource import ServiceResourceQueuesCollection
from types_aiobotocore_sqs.service_resource import Queue
session = Session()
resource: SQSServiceResource
async with session.resource("sqs") as resource: # (1)
collection: ServiceResourceQueuesCollection = resource.queues # (2)
for item in collection:
item: Queue
print(item) # (3)
- resource: SQSServiceResource
- collection: SQSServiceResource
- item: Queue