Skip to main content

Type annotations for boto3.S3 1.14.0 service, generated by mypy-boto3-buider 2.2.0

Project description

mypy-boto3-s3

PyPI - mypy-boto3-s3 PyPI - Python Version Docs

Type annotations for boto3.S3 1.14.0 service compatible with mypy, VSCode, PyCharm and other tools.

Generated by mypy-boto3-buider 2.2.0.

More information can be found on boto3-stubs page.

How to install

Make sure you have mypy installed and activated in your IDE.

Install boto3-stubs for S3 service.

python -m pip install boto3-stubs[s3]

How to use

Client annotations

S3Client provides annotations for boto3.client("s3").

import boto3

from mypy_boto3_s3 import S3Client, S3ServiceResource
from mypy_boto3_s3.paginator import (
    ListMultipartUploadsPaginator,
    ListObjectsPaginator,
    ListObjectsV2Paginator,
    ListObjectVersionsPaginator,
    ListPartsPaginator,
)
from mypy_boto3_s3.service_resource import (
    Bucket,
    BucketAcl,
    BucketCors,
    BucketLifecycle,
    BucketLifecycleConfiguration,
    BucketLogging,
    BucketNotification,
    BucketPolicy,
    BucketRequestPayment,
    BucketTagging,
    BucketVersioning,
    BucketWebsite,
    MultipartUpload,
    MultipartUploadPart,
    Object,
    ObjectAcl,
    ObjectSummary,
    ObjectVersion,
    ServiceResourceBucketsCollection,
)
from mypy_boto3_s3.type_defs import AbortIncompleteMultipartUploadTypeDef, ...
from mypy_boto3_s3.waiter import (
    BucketExistsWaiter,
    BucketNotExistsWaiter,
    ObjectExistsWaiter,
    ObjectNotExistsWaiter,
)

client: S3Client = boto3.client("s3")

# now client usage is checked by mypy and IDE should provide code auto-complete

# works for session as well
session = boto3.session.Session(region="us-west-1")
session_client: S3Client = session.client("s3")

Paginators annotations

mypy_boto3_s3.paginator module contains type annotations for all paginators.

client: S3Client = boto3.client("s3")

# Explicit type annotations are optional here
# Type should be correctly discovered by mypy and IDEs
# VSCode requires explicit type annotations
list_multipart_uploads_paginator: ListMultipartUploadsPaginator = client.get_paginator("list_multipart_uploads")
list_object_versions_paginator: ListObjectVersionsPaginator = client.get_paginator("list_object_versions")
list_objects_paginator: ListObjectsPaginator = client.get_paginator("list_objects")
list_objects_v2_paginator: ListObjectsV2Paginator = client.get_paginator("list_objects_v2")
list_parts_paginator: ListPartsPaginator = client.get_paginator("list_parts")

Waiters annotations

mypy_boto3_s3.waiter module contains type annotations for all waiters.

client: S3Client = boto3.client("s3")

# Explicit type annotations are optional here
# Type should be correctly discovered by mypy and IDEs
# VSCode requires explicit type annotations
bucket_exists_waiter: BucketExistsWaiter = client.get_waiter("bucket_exists")
bucket_not_exists_waiter: BucketNotExistsWaiter = client.get_waiter("bucket_not_exists")
object_exists_waiter: ObjectExistsWaiter = client.get_waiter("object_exists")
object_not_exists_waiter: ObjectNotExistsWaiter = client.get_waiter("object_not_exists")

Service Resource annotations

S3ServiceResource provides annotations for boto3.resource("s3").

resource: S3ServiceResource = boto3.resource("s3")

# now resource usage is checked by mypy and IDE should provide code auto-complete

# works for session as well
session = boto3.session.Session(region="us-west-1")
session_resource: S3ServiceResource = session.resource("s3")

Other resources annotations

mypy_boto3_s3.service_resource module contains type annotations for all resources.

resource: S3ServiceResource = boto3.resource("s3")

# Explicit type annotations are optional here
# Type should be correctly discovered by mypy and IDEs
my_bucket: Bucket = resource.Bucket(...)
my_bucket_acl: BucketAcl = resource.BucketAcl(...)
my_bucket_cors: BucketCors = resource.BucketCors(...)
my_bucket_lifecycle: BucketLifecycle = resource.BucketLifecycle(...)
my_bucket_lifecycle_configuration: BucketLifecycleConfiguration = resource.BucketLifecycleConfiguration(...)
my_bucket_logging: BucketLogging = resource.BucketLogging(...)
my_bucket_notification: BucketNotification = resource.BucketNotification(...)
my_bucket_policy: BucketPolicy = resource.BucketPolicy(...)
my_bucket_request_payment: BucketRequestPayment = resource.BucketRequestPayment(...)
my_bucket_tagging: BucketTagging = resource.BucketTagging(...)
my_bucket_versioning: BucketVersioning = resource.BucketVersioning(...)
my_bucket_website: BucketWebsite = resource.BucketWebsite(...)
my_multipart_upload: MultipartUpload = resource.MultipartUpload(...)
my_multipart_upload_part: MultipartUploadPart = resource.MultipartUploadPart(...)
my_object: Object = resource.Object(...)
my_object_acl: ObjectAcl = resource.ObjectAcl(...)
my_object_summary: ObjectSummary = resource.ObjectSummary(...)
my_object_version: ObjectVersion = resource.ObjectVersion(...)

Collections annotations

mypy_boto3_s3.service_resource module contains type annotations for all S3ServiceResource collections.

resource: S3ServiceResource = boto3.resource("s3")

# Explicit type annotations are optional here
# Type should be correctly discovered by mypy and IDEs
buckets: s3_resources.ServiceResourceBucketsCollection = resource.buckets

Typed dictionations

mypy_boto3_s3.type_defs module contains structures and shapes assembled to typed dictionaries for additional type checking.

def get_structure() -> AbortIncompleteMultipartUploadTypeDef:
    return {
      ...
    }

Dynamic type annotations

mypy_boto3 command generates boto3.client/resource type annotations for mypy_boto3_s3 and other installed services.

# Run this command after you add or remove service packages
python -m mypy_boto3

Generated type annotations provide overloads for boto3.client and boto3.resource, boto3.Session.client and boto3.Session.resource functions, so explicit type annotations are not needed.

  • mypy supports function overloads as expected
  • PyCharm also supports function overloads, but consumes a lot of RAM, use carefully if you have many services installed
  • VSCode does not currently support function overloads, use explicit type annotations
# Type is discovered correctly by mypy and PyCharm
# VSCode still needs explicit type annotations
client = boto3.client("s3")
resource = boto3.resource("s3")

session_client = boto3.Session().client("s3")
session_resource = boto3.Session().resource("s3")

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mypy-boto3-s3-1.14.0.2.tar.gz (25.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mypy_boto3_s3-1.14.0.2-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file mypy-boto3-s3-1.14.0.2.tar.gz.

File metadata

  • Download URL: mypy-boto3-s3-1.14.0.2.tar.gz
  • Upload date:
  • Size: 25.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for mypy-boto3-s3-1.14.0.2.tar.gz
Algorithm Hash digest
SHA256 9d0a111d35edde93a52c83e88e761ca2110ed9bb6319bda3ec61f105ca2e78c0
MD5 a92284d0a55821ccc0eae6f582ecff4a
BLAKE2b-256 f6d1eecba245ab2e5611021df8b3ee8de58587567e3d0fc1bceb10c2be5c4dad

See more details on using hashes here.

File details

Details for the file mypy_boto3_s3-1.14.0.2-py3-none-any.whl.

File metadata

  • Download URL: mypy_boto3_s3-1.14.0.2-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for mypy_boto3_s3-1.14.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 81ce8a865f473f25032777786f4027112349b3f78c0ad7f7d09b0e9e7972fcfa
MD5 2b16ce9d5b498d1aeeb1e597528a55d4
BLAKE2b-256 1cb323ccead1a9480f1dbe46634cb853f3cdec7ce82630960bed9b61febaa6e4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page