{"id":3120,"library":"mypy-boto3-organizations","title":"mypy-boto3-organizations - Type annotations for AWS Organizations","description":"mypy-boto3-organizations provides type annotations for the `boto3` AWS SDK's Organizations service. It enhances static type checking with tools like `mypy` and `pyright`, offering improved code quality and IDE support. This package, currently at version 1.42.83, is automatically generated by `mypy-boto3-builder` and frequently updated to maintain compatibility with `boto3` releases.","status":"active","version":"1.42.83","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["AWS","boto3","mypy","type hints","organizations","stubs","static analysis"],"install":[{"cmd":"pip install mypy-boto3-organizations","lang":"bash","label":"Install standalone package"},{"cmd":"pip install 'boto3-stubs[organizations]'","lang":"bash","label":"Install as part of boto3-stubs"}],"dependencies":[{"reason":"Provides type annotations for the boto3 library.","package":"boto3","optional":false}],"imports":[{"symbol":"OrganizationsClient","correct":"from mypy_boto3_organizations import OrganizationsClient"},{"symbol":"AcceptHandshakeRequestTypeDef","correct":"from mypy_boto3_organizations.type_defs import AcceptHandshakeRequestTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_organizations import OrganizationsClient\nfrom mypy_boto3_organizations.type_defs import CreateAccountRequestTypeDef, CreateAccountResponseTypeDef\n\n\ndef create_aws_account(account_name: str, email: str, role_name: str) -> CreateAccountResponseTypeDef:\n    \"\"\"Creates a new AWS account within an organization.\"\"\"\n    client: OrganizationsClient = boto3.client(\"organizations\")\n    \n    request: CreateAccountRequestTypeDef = {\n        \"Email\": email,\n        \"AccountName\": account_name,\n        \"RoleName\": role_name,\n        \"Tags\": [\n            {\"Key\": \"Project\", \"Value\": \"MyProject\"}\n        ]\n    }\n    \n    response: CreateAccountResponseTypeDef = client.create_account(**request)\n    print(f\"Account creation requested: {response['CreateAccountStatus']['State']}\")\n    print(f\"Account ID: {response['CreateAccountStatus'].get('AccountId', 'N/A')}\")\n    return response\n\n# Example usage (requires AWS credentials configured for Organizations service)\nif __name__ == \"__main__\":\n    # In a real scenario, use unique values and ensure email is valid\n    # and not already associated with an AWS account.\n    # Replace with actual email and account name for testing.\n    test_account_name = \"MyTestOrgAccount\"\n    test_email = \"test-account-owner@example.com\" # Use a real, unique email\n    test_role_name = \"OrganizationAccountAccessRole\"\n    \n    try:\n        # This call will actually attempt to create an account in your AWS Organizations.\n        # Be cautious when running this in a production environment.\n        # For demonstration purposes, we'll comment out the actual call.\n        # response = create_aws_account(test_account_name, test_email, test_role_name)\n        print(\"To run, uncomment the create_aws_account call with valid parameters.\")\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n","lang":"python","description":"Demonstrates how to use `mypy-boto3-organizations` to type-hint a `boto3` Organizations client and its method calls, including request and response `TypeDef` objects. This allows static analysis tools to validate your AWS API interactions."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher.","message":"Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0. Consequently, `mypy-boto3-organizations` (and other generated stubs) now require Python 3.9 or newer.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0, mypy-boto3-organizations >= 1.42.83 (as generated)"},{"fix":"Verify your type checker (e.g., mypy) is up-to-date and configured to correctly find stub packages. No direct code change is usually needed unless custom stub resolution paths were used.","message":"The `mypy-boto3-builder` migrated to PEP 561-compliant packages in version 8.12.0. While this generally improves type checker compatibility, users might need to ensure their `mypy` or `pyright` configurations correctly resolve type stubs.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0, mypy-boto3-organizations >= 1.42.83 (as generated)"},{"fix":"Update your code to use the new, shorter TypeDef names for request/response bodies as per the updated generated stubs. Consult the specific service's documentation for the correct TypeDef names.","message":"TypeDef naming conventions changed in `mypy-boto3-builder` 8.9.0. Specifically, packed method arguments may use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). This applies to all generated service stubs, including Organizations.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.9.0"},{"fix":"Add explicit type annotations to your `boto3.client` and `session.client` calls to leverage full type-checking benefits.","message":"For optimal IDE auto-completion and static analysis, it is recommended to explicitly type-hint `boto3.client` calls with the imported client type (e.g., `client: OrganizationsClient = boto3.client(\"organizations\")`), especially when using standalone service stub packages like `mypy-boto3-organizations`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If migrating from `mypy-boto3`, switch to `boto3-stubs` or the relevant `mypy-boto3-{service_name}` package. Ensure your imports reflect the new package structure (e.g., `from mypy_boto3_organizations import OrganizationsClient`).","message":"The `mypy-boto3` library is a legacy package. The current recommendation for `boto3` type annotations is to use `boto3-stubs` (for a collection of services) or specific standalone packages like `mypy-boto3-organizations`.","severity":"gotcha","affected_versions":"Older projects using `mypy-boto3` directly."}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}