Skip to content

S3 module#

Index > S3

Auto-generated documentation for S3 type annotations stubs module mypy-boto3-s3.

How to install#

VSCode extension#

Add AWS Boto3 extension to your VSCode and run AWS boto3: Quick Start command.

Click Modify and select boto3 common and S3.

From PyPI with pip#

Install boto3-stubs for S3 service.

# install with boto3 type annotations
python -m pip install 'boto3-stubs[s3]'


# Lite version does not provide session.client/resource overloads
# it is more RAM-friendly, but requires explicit type annotations
python -m pip install 'boto3-stubs-lite[s3]'


# standalone installation
python -m pip install mypy-boto3-s3

From conda-forge#

Installing mypy-boto3-s3 from the conda-forge channel can be achieved by adding conda-forge to your channels with:

conda config --add channels conda-forge
conda config --set channel_priority strict

Once the conda-forge channel has been enabled, mypy-boto3-s3 can be installed with:

conda install mypy-boto3-s3

It is possible to list all of the versions of mypy-boto3-s3 available on your platform with:

conda search mypy-boto3-s3 --channel conda-forge

How to uninstall#

python -m pip uninstall -y mypy-boto3-s3

Usage#

Code samples can be found in Examples.

S3Client#

Type annotations and code completion for boto3.client("s3") as S3Client boto3 documentation

# S3Client usage example

from boto3.session import Session

from mypy_boto3_s3.client import S3Client

def get_client() -> S3Client:
    return Session().client("s3")

Paginators#

Type annotations and code completion for paginators from boto3.client("s3").get_paginator("...").

# ListBucketsPaginator usage example

from boto3.session import Session

from mypy_boto3_s3.paginator import ListBucketsPaginator

def get_list_buckets_paginator() -> ListBucketsPaginator:
    return Session().client("s3").get_paginator("list_buckets"))

Waiters#

Type annotations and code completion for waiters from boto3.client("s3").get_waiter("...").

# BucketExistsWaiter usage example

from boto3.session import Session

from mypy_boto3_s3.waiter import BucketExistsWaiter

def get_bucket_exists_waiter() -> BucketExistsWaiter:
    return Session().client("s3").get_waiter("bucket_exists")

S3ServiceResource#

Type annotations and code completion for boto3.resource("s3") as S3ServiceResource boto3 documentation

# S3ServiceResource usage example

from boto3.session import Session

from mypy_boto3_s3.service_resource import S3ServiceResource

def get_s3_resource() -> S3ServiceResource:
    return Session().resource("s3")

Collections#

Type annotations and code completion for collections from boto3.resource("s3").*.

# ServiceResourceBucketsCollection usage example

from boto3.session import Session

from mypy_boto3_s3.service_resource import ServiceResourceBucketsCollection

def get_collection() -> ServiceResourceBucketsCollection:
    return Session().resource("s3").buckets

Resources#

Type annotations and code completion for additional resources from session.resource("s3").*.

# Bucket usage example

from mypy_boto3_s3.service_resource import Bucket

def get_resource() -> Bucket:
    return resource.Bucket(...)

Literals#

Type annotations for literals used in methods and schema.

# AnalyticsS3ExportFileFormatType usage example

from mypy_boto3_s3.literals import AnalyticsS3ExportFileFormatType

def get_value() -> AnalyticsS3ExportFileFormatType:
    return "CSV"

Type definitions#

Type annotations for type definitions used in methods and schema.