Type Stubs for botocore (Deprecated)

1.0.2 · deprecated · verified Mon Apr 13

This is a deprecated proxy package that historically provided type stubs for `botocore`. It has been superseded by `mypy-boto3-botocore` and other comprehensive stub packages generated by the `mypy_boto3_builder` project. Users should avoid installing this package, as its version is extremely outdated and it will not provide accurate or complete type hints for modern `botocore` versions.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `mypy-boto3` to get type stubs for `botocore` (and `boto3`). It specifically advises *against* installing `types-botocore` due to its deprecated status. The example shows how to correctly type an S3 client and call a method, relying on `mypy-boto3` for accurate type hints.

import boto3
from typing import TYPE_CHECKING

# NOTE: Do NOT install 'types-botocore'. It is deprecated.
# Instead, install 'mypy-boto3' for comprehensive type stubs for boto3 and botocore.
# pip install mypy-boto3

# Example usage with proper type stubs (via mypy-boto3):

if TYPE_CHECKING:
    # These imports are for type checking only and are provided by mypy-boto3-s3
    from mypy_boto3_s3.client import S3Client
    from mypy_boto3_s3.type_defs import CreateBucketOutputTypeDef


def create_s3_bucket(bucket_name: str, region: str) -> None:
    # When mypy-boto3 is installed, boto3.client('s3') will be correctly typed.
    # For explicit type annotation, you can use the imported S3Client type.
    client: S3Client = boto3.client('s3', region_name=region)
    print(f"Attempting to create bucket: {bucket_name} in {region}")
    try:
        response: CreateBucketOutputTypeDef = client.create_bucket(
            Bucket=bucket_name,
            CreateBucketConfiguration={'LocationConstraint': region}
        )
        print(f"Bucket creation successful: {response}")
    except client.exceptions.BucketAlreadyOwnedByYou:
        print(f"Bucket {bucket_name} already exists and is owned by you.")
    except Exception as e:
        print(f"Error creating bucket: {e}")


if __name__ == "__main__":
    # Replace with your desired bucket name and region
    # Use environment variables for sensitive info in real applications
    # Or ensure AWS credentials are configured (e.g., via ~/.aws/credentials)
    test_bucket_name = "my-unique-test-bucket-1234567890"
    test_region = "us-east-1"
    create_s3_bucket(test_bucket_name, test_region)

view raw JSON →