{"id":3301,"library":"types-aiobotocore-ec2","title":"Type Annotations for aiobotocore EC2","description":"This library provides comprehensive type annotations for the aiobotocore EC2 service (version 3.4.0), generated by `mypy-boto3-builder`. It enables static type checking with tools like MyPy and Pyright, offering improved developer experience for asynchronous AWS interactions. The project maintains an active release cadence, often aligning with `aiobotocore` and `botocore` updates.","status":"active","version":"3.4.0","language":"python","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","aiobotocore","ec2","types","mypy","typing","stubs","type-hinting"],"install":[{"cmd":"pip install types-aiobotocore-ec2","lang":"bash","label":"Install standalone package"},{"cmd":"pip install 'types-aiobotocore[ec2]'","lang":"bash","label":"Install as part of 'types-aiobotocore' umbrella package"}],"dependencies":[{"reason":"This package provides type stubs for aiobotocore. The runtime library is required for execution.","package":"aiobotocore","optional":false},{"reason":"While Python 3.9+ is required, aiobotocore itself lists typing-extensions as a dependency, and the builder ensures its version compatibility.","package":"typing-extensions","optional":false}],"imports":[{"wrong":"from types_aiobotocore_ec2 import EC2Client","symbol":"EC2Client","correct":"from types_aiobotocore_ec2 import EC2Client"}],"quickstart":{"code":"import asyncio\nfrom aiobotocore.session import get_session\nfrom typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n    from types_aiobotocore_ec2.client import EC2Client\n    from types_aiobotocore_ec2.type_defs import DescribeInstancesResultTypeDef\n\nasync def describe_ec2_instances():\n    session = get_session()\n    async with session.create_client(\"ec2\") as client:\n        # Explicit type annotation for the client\n        client: \"EC2Client\" = client\n        response = await client.describe_instances()\n        \n        print(f\"Found {len(response['Reservations'])} reservations.\")\n        for reservation in response['Reservations']:\n            for instance in reservation['Instances']:\n                print(f\"  Instance ID: {instance['InstanceId']}, State: {instance['State']['Name']}\")\n        \n        # Example of using a TypeDef for a dictionary structure\n        example_type_def: \"DescribeInstancesResultTypeDef\" = response\n        print(f\"Example TypeDef Reservations key: {example_type_def['Reservations'][0]['ReservationId']}\")\n\nif __name__ == \"__main__\":\n    asyncio.run(describe_ec2_instances())\n","lang":"python","description":"This example demonstrates how to set up an `aiobotocore` client for EC2 and apply type annotations using `types-aiobotocore-ec2`. It explicitly types the client and shows how to leverage TypeDefs for response objects, enabling better static analysis and IDE autocompletion for asynchronous AWS calls."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer.","message":"Support for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0 and subsequent generated packages. Users on Python 3.8 must either upgrade Python or use an older version of `types-aiobotocore-ec2`.","severity":"breaking","affected_versions":">=3.4.0 (for types-aiobotocore-ec2), >=8.12.0 (for mypy-boto3-builder)"},{"fix":"Review your type hints and update TypeDef names according to the latest generated types if you experience `NameError` or type resolution issues.","message":"Generated TypeDef naming conventions may have changed in `mypy-boto3-builder` version 8.9.0. For instance, `CreateDistributionRequestRequestTypeDef` might become `CreateDistributionRequestTypeDef`. Code relying on specific TypeDef names may break.","severity":"breaking","affected_versions":">=3.x.x (for types-aiobotocore-ec2), >=8.9.0 (for mypy-boto3-builder)"},{"fix":"Ensure both `aiobotocore` and `types-aiobotocore-ec2` are installed in your environment.","message":"Installing `types-aiobotocore-ec2` only provides type annotations. For actual runtime execution, you must also install the `aiobotocore` library itself (`pip install aiobotocore`).","severity":"gotcha","affected_versions":"all"},{"fix":"Add explicit type annotations for clients, resources, paginators, and waiters imported from `types_aiobotocore_ec2`.","message":"When using standalone service packages like `types-aiobotocore-ec2` or `types-aiobotocore-lite`, explicit type annotations (e.g., `client: EC2Client`) are often required for full type checking and IDE support. The main `types-aiobotocore` package with overloads can sometimes infer types implicitly.","severity":"gotcha","affected_versions":"all"},{"fix":"Consider using the `-lite` version of the stubs (`types-aiobotocore-lite-ec2` if available) or disable PyCharm's internal type checker and rely on external tools like MyPy or Pyright instead.","message":"PyCharm users might experience slow performance or high CPU usage due to the large number of `Literal` overloads in these stub packages (related to PyCharm issue PY-40997).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'3.4.0':18 'activ':48 'aiobotocor':4,14,54,59 'align':52 'annot':2,11 'asynchron':41 'aw':42,58 'boto3':23 'botocor':56 'builder':24 'cadenc':50 'check':29 'comprehens':9 'develop':38 'ec2':5,15,60 'enabl':26 'experi':39 'generat':19 'hint':67 'improv':37 'interact':43 'librari':7 'like':32 'maintain':46 'mypi':22,33,62 'mypy-boto3-builder':21 'offer':36 'often':51 'project':45 'provid':8 'pyright':35 'releas':49 'servic':16 'static':27 'stub':64 'tool':31 'type':1,10,28,61,63,66 'type-hint':65 'updat':57 'version':17","created_at":"2026-04-11T09:29:38.153569+00:00","updated_at":"2026-04-11T09:29:38.153569+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/tmp/tmpmzrnbbe5/venv/lib/python3.12/site-packages/types_aiobotocore_ec2/__init__.py\", line 455, in <module>\n    from .client import EC2Client\n  File \"/tmp/tmpmzrnbbe5/venv/lib/python3.12/site-packages/types_aiobotocor"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"3.9.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/youtype/mypy_boto3_builder","docs":"https://youtype.github.io/types_aiobotocore_docs/types_aiobotocore_ec2/","changelog":null,"pypi":"https://pypi.org/project/types-aiobotocore-ec2/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["type-stubs","aws"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-07-03","last_verified":"2026-08-29","next_check":"2026-07-10","install_tag":null}}