Type Stubs for botocore (Deprecated)
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
- breaking The `types-botocore` package is deprecated and no longer actively maintained. Its version 1.0.2 is extremely outdated and will not provide accurate or complete type stubs for modern `botocore` versions.
- gotcha Installing `types-botocore` will not provide the expected type-checking functionality or IDE auto-completion for current `botocore` usage. It's a legacy package that has been superseded by the robust `mypy_boto3_builder` ecosystem.
- breaking The release notes provided in the prompt (e.g., versions like `8.12.0`, `8.11.0`) are for the `mypy_boto3_builder` project and its generated stub packages (like `mypy-boto3` and `mypy-boto3-botocore`), *not* for the `types-botocore` package itself. `types-botocore` is explicitly stuck at version 1.0.2.
Install
-
pip install types-botocore
Imports
- Client
from botocore.client import Client
Quickstart
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)