Examples
Auto-generated documentation for Glacier type annotations stubs module mypy-boto3-glacier.
Client
Implicit type annotations
Can be used with boto3-stubs[glacier]
package installed.
Write your Glacier
code as usual,
type checking and code completion should work out of the box.
from boto3.session import Session
session = Session()
client = session.client("glacier") # (1)
result = client.abort_multipart_upload() # (2)
- client: GlacierClient
- result: EmptyResponseMetadataTypeDef
from boto3.session import Session
session = Session()
client = session.client("glacier") # (1)
paginator = client.get_paginator("list_jobs") # (2)
for item in paginator.paginate(...):
print(item) # (3)
- client: GlacierClient
- paginator: ListJobsPaginator
- item: ListJobsOutputTypeDef
from boto3.session import Session
session = Session()
client = session.client("glacier") # (1)
waiter = client.get_waiter("vault_exists") # (2)
waiter.wait()
- client: GlacierClient
- waiter: VaultExistsWaiter
Explicit type annotations
With boto3-stubs-lite[glacier]
or a standalone mypy_boto3_glacier
package, you have to explicitly specify client: GlacierClient
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 boto3.session import Session
from mypy_boto3_glacier.client import GlacierClient
from mypy_boto3_glacier.type_defs import EmptyResponseMetadataTypeDef
from mypy_boto3_glacier.type_defs import AbortMultipartUploadInputRequestTypeDef
session = Session()
client: GlacierClient = session.client("glacier")
kwargs: AbortMultipartUploadInputRequestTypeDef = {...}
result: EmptyResponseMetadataTypeDef = client.abort_multipart_upload(**kwargs)
from boto3.session import Session
from mypy_boto3_glacier.client import GlacierClient
from mypy_boto3_glacier.paginator import ListJobsPaginator
from mypy_boto3_glacier.type_defs import ListJobsOutputTypeDef
session = Session()
client: GlacierClient = session.client("glacier")
paginator: ListJobsPaginator = client.get_paginator("list_jobs")
for item in paginator.paginate(...):
item: ListJobsOutputTypeDef
print(item)
from boto3.session import Session
from mypy_boto3_glacier.client import GlacierClient
from mypy_boto3_glacier.waiter import VaultExistsWaiter
session = Session()
client: GlacierClient = session.client("glacier")
waiter: VaultExistsWaiter = client.get_waiter("vault_exists")
waiter.wait()
Service Resource
Implicit type annotations
Can be used with boto3-stubs[glacier]
package installed.
from boto3.session import Session
session = Session()
resource = session.resource("glacier") # (1)
result = resource.Account() # (2)
- resource: GlacierServiceResource
- result:
from boto3.session import Session
session = Session()
resource = session.resource("glacier") # (1)
collection = resource.vaults # (2)
for item in collection:
print(item) # (3)
- resource: GlacierServiceResource
- collection: GlacierServiceResource
- item: Vault
Explicit type annotations
With boto3-stubs-lite[glacier]
or a standalone mypy_boto3_glacier
package, you have to explicitly specify
resource: GlacierServiceResource
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 boto3.session import Session
from mypy_boto3_glacier.service_resource import GlacierServiceResource
from mypy_boto3_glacier.service_resource import Account
session = Session()
resource: GlacierServiceResource = session.resource("glacier")
result: Account = resource.Account()
from boto3.session import Session
from mypy_boto3_glacier.service_resource import GlacierServiceResource
from mypy_boto3_glacier.service_resource import ServiceResourceVaultsCollection
from mypy_boto3_glacier.service_resource import Vault
session = Session()
resource: GlacierServiceResource = session.resource("glacier")
collection: ServiceResourceVaultsCollection = resource.vaults
for item in collection:
item: Vault
print(item)