{"id":3072,"library":"mypy-boto3-directconnect","title":"mypy-boto3-directconnect Type Annotations","description":"mypy-boto3-directconnect provides type annotations for the `boto3` AWS Direct Connect service client. It ensures type-safe usage of `boto3` calls related to Direct Connect in Python projects, catching potential errors during static analysis with `mypy`. The current version is `1.42.3`, and it's released in conjunction with `boto3` updates and `mypy-boto3-builder` enhancements.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["AWS","Boto3","Type Checking","Mypy","Stubs","Direct Connect","Static Analysis"],"install":[{"cmd":"pip install mypy-boto3-directconnect boto3 mypy","lang":"bash","label":"Install with boto3 and mypy"}],"dependencies":[{"reason":"Runtime dependency for the AWS SDK functions being type-checked.","package":"boto3"},{"reason":"Required for static type checking.","package":"mypy"},{"reason":"May be a dependency for older Python versions, automatically managed by builder.","package":"typing-extensions","optional":true}],"imports":[{"note":"While `client` submodule import works, the top-level package import is idiomatic for the main client type.","wrong":"from mypy_boto3_directconnect.client import DirectConnectClient","symbol":"DirectConnectClient","correct":"from mypy_boto3_directconnect import DirectConnectClient"},{"symbol":"DescribeConnectionsPaginator","correct":"from mypy_boto3_directconnect.paginator import DescribeConnectionsPaginator"},{"symbol":"ConnectionStatusType","correct":"from mypy_boto3_directconnect.type_defs import ConnectionStatusType"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_directconnect import DirectConnectClient\nfrom mypy_boto3_directconnect.type_defs import ConnectionTypePairTypeDef\n\ndef list_direct_connect_connections() -> None:\n    # Initialize the boto3 client with type hints\n    client: DirectConnectClient = boto3.client('directconnect')\n\n    print(\"Listing Direct Connect connections...\")\n    try:\n        response = client.describe_connections()\n        for connection in response.get('connections', []):\n            print(f\"  Connection ID: {connection['connectionId']}\")\n            print(f\"  Connection Name: {connection['connectionName']}\")\n            print(f\"  Connection State: {connection['connectionState']}\")\n            if 'connectionType' in connection:\n                # Example of using a TypedDict for a specific field\n                type_info: ConnectionTypePairTypeDef = {\n                    'connectionType': connection['connectionType']\n                }\n                print(f\"  Connection Type: {type_info['connectionType']}\")\n\n    except Exception as e:\n        print(f\"Error listing connections: {e}\")\n\nif __name__ == '__main__':\n    list_direct_connect_connections()","lang":"python","description":"This quickstart demonstrates how to use `mypy-boto3-directconnect` to add type hints to your `boto3` Direct Connect client. It shows how to import the `DirectConnectClient` type and apply it to a `boto3.client()` call, enabling `mypy` to validate your service interactions. It also includes an example of importing and using a specific `TypeDef` for enhanced type safety when accessing response data."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer. Ensure your CI/CD pipelines reflect this change.","message":"Python 3.8 is no longer supported. `mypy-boto3-builder` version 8.12.0 and subsequent packages (including `mypy-boto3-directconnect`) require Python 3.9 or higher.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0 and generated packages"},{"fix":"Verify your `mypy` configuration (e.g., `mypy_path`) is compatible with PEP 561 package discovery. In most standard setups, no manual changes should be required.","message":"The `mypy-boto3-builder` migrated to PEP 561 packages, which may affect how `mypy` discovers and uses the type stubs, especially for custom configurations.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0 and generated packages"},{"fix":"Always install `mypy-boto3-directconnect` with a version that closely matches your `boto3` version. For example, if `boto3` is `1.26.x`, try `mypy-boto3-directconnect~=1.26.x`.","message":"Version mismatch between `boto3` and `mypy-boto3-*` stubs can lead to incorrect type checking or missing types. These packages are generated for specific `boto3` versions.","severity":"gotcha","affected_versions":"All"},{"fix":"If upgrading from older versions, review your code for explicit imports or usage of TypedDicts, especially for API request parameters, and update names if they changed for your service.","message":"Service-specific TypedDict names were shortened or adjusted in `mypy-boto3-builder` 8.9.0 to avoid conflicts or reduce verbosity (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`).","severity":"gotcha","affected_versions":"mypy-boto3-builder >= 8.9.0 and generated packages"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}