mypy-boto3-pcs Type Stubs
mypy-boto3-pcs provides type annotations for the `boto3` ParallelComputingService, enhancing code completion and static analysis with tools like MyPy. It is part of the `mypy-boto3` project, which auto-generates type stubs for all `boto3` services and is actively maintained with frequent updates mirroring `boto3` releases.
Warnings
- breaking Support for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0. All generated `mypy-boto3` packages, including `mypy-boto3-pcs`, now require Python 3.9 or higher.
- breaking In `mypy-boto3-builder` version 8.9.0, TypeDef names for packed method arguments were shortened (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). This can cause type-checking errors if you were explicitly referencing the older, longer TypeDef names.
- gotcha `mypy-boto3-pcs` only provides type stubs, not the `boto3` library itself. You *must* install `boto3` separately for your code to function at runtime. The type stubs are solely for static analysis.
- gotcha While direct installation like `pip install mypy-boto3-pcs` works, for comprehensive `boto3` type-hinting across multiple services, the `boto3-stubs` package with extras (e.g., `pip install 'boto3-stubs[full]'` or `pip install 'boto3-stubs[pcs]'`) is often recommended as the primary entry point for type annotations. This ensures consistency and proper integration for all services you use.
- deprecated Some AWS service names or their corresponding `mypy-boto3` stub packages may be deprecated or renamed over time, reflecting changes in the AWS SDK. For example, the `sms-voice` service was removed in `mypy-boto3-builder` 8.11.0, with `pinpoint-sms-voice` as its replacement.
Install
-
pip install mypy-boto3-pcs boto3
Imports
- ParallelComputingServiceClient
from mypy_boto3_pcs.client import ParallelComputingServiceClient
- ParallelComputingServiceClient
import boto3 from mypy_boto3_pcs.client import ParallelComputingServiceClient def get_pcs_client() -> ParallelComputingServiceClient: return boto3.client('pcs')
Quickstart
import boto3
from mypy_boto3_pcs.client import ParallelComputingServiceClient
from os import environ
# Ensure boto3 is installed: pip install boto3 mypy-boto3-pcs
def get_pcs_client() -> ParallelComputingServiceClient:
"""Returns a type-hinted ParallelComputingService client."""
# Boto3 client creation with type hint
client: ParallelComputingServiceClient = boto3.client(
'pcs',
region_name=environ.get('AWS_REGION', 'us-east-1'),
aws_access_key_id=environ.get('AWS_ACCESS_KEY_ID', ''),
aws_secret_access_key=environ.get('AWS_SECRET_ACCESS_KEY', '')
)
return client
if __name__ == '__main__':
pcs_client = get_pcs_client()
# Now `pcs_client` has type hints for ParallelComputingService methods
print(f"Client type: {type(pcs_client)}")
# Example of a method call (replace with actual PCS method if needed)
# This specific service 'pcs' is less common for simple public examples.
# print(pcs_client.list_resources())