Type Annotations for Boto3 S3Outposts
mypy-boto3-s3outposts provides type annotations for the `boto3` S3Outposts service, enhancing development with static type checking and IDE autocomplete. It is generated by `mypy-boto3-builder` and keeps pace with `boto3` releases, typically seeing frequent updates. The current version is 1.42.3.
Warnings
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0, which generates `mypy-boto3-s3outposts`. Users on Python 3.8 should upgrade their Python version.
- breaking As of `mypy-boto3-builder` version 8.12.0, the generated stub packages fully migrated to PEP 561. This change generally improves compatibility but may require updates to `mypy` or IDE configurations for older setups.
- breaking In `mypy-boto3-builder` version 8.9.0, TypeDef naming conventions changed. For example, `CreateDistributionRequestRequestTypeDef` was shortened to `CreateDistributionRequestTypeDef`. This affects all generated service TypeDefs, including those for S3Outposts.
- gotcha While `mypy-boto3` stubs generally allow implicit type discovery, explicit type annotations (e.g., `client: S3OutpostsClient = session.client('s3outposts')`) are often recommended for the best IDE autocomplete and type checker experience, especially when using `mypy-boto3-lite` variants.
- gotcha Pylint may report 'undefined variable' errors when using `TYPE_CHECKING` blocks to conditionally import stubs. This is a known issue with Pylint's static analysis.
Install
-
pip install mypy-boto3-s3outposts boto3
Imports
- S3OutpostsClient
from mypy_boto3_s3outposts.client import S3OutpostsClient
- ListEndpointsPaginator
from mypy_boto3_s3outposts.paginator import ListEndpointsPaginator
- CreateEndpointRequestTypeDef
from mypy_boto3_s3outposts.type_defs import CreateEndpointRequestTypeDef
- Session
from boto3.session import Session
Quickstart
import os
from typing import TYPE_CHECKING
import boto3
from boto3.session import Session
if TYPE_CHECKING:
from mypy_boto3_s3outposts.client import S3OutpostsClient
from mypy_boto3_s3outposts.type_defs import CreateEndpointRequestTypeDef
def get_s3outposts_client() -> 'S3OutpostsClient':
# Explicit type annotation is optional with full mypy-boto3-stubs
# but can be helpful for IDEs and type checkers like mypy/pyright.
session = Session(region_name=os.environ.get('AWS_DEFAULT_REGION', 'us-east-1'))
client: S3OutpostsClient = session.client('s3outposts')
return client
if __name__ == "__main__":
s3outposts_client = get_s3outposts_client()
print("Listing S3Outposts endpoints:")
try:
response = s3outposts_client.list_endpoints()
for endpoint in response.get("Endpoints", []):
print(f" Endpoint Id: {endpoint.get('EndpointId')}, Status: {endpoint.get('Status')}")
except Exception as e:
print(f"Error listing endpoints: {e}")
# Example of using a TypedDict for a request payload (if creating an endpoint)
# Note: This is a placeholder and would require actual valid parameters to run.
if TYPE_CHECKING:
create_endpoint_request: CreateEndpointRequestTypeDef = {
"OutpostId": "op-0123456789abcdef0",
"S3OutpostsArn": "arn:aws:s3-outposts:us-east-1:123456789012:outpost/op-0123456789abcdef0/accesspoint/my-accesspoint",
"EndpointDetails": {
"SecurityGroupId": "sg-0abcdef1234567890",
"SubnetId": "subnet-0abcdef1234567890"
}
}
# result = s3outposts_client.create_endpoint(**create_endpoint_request)
# print(f"Created endpoint: {result.get('EndpointArn')}")