{"id":3562,"library":"mypy-boto3-billing","title":"mypy-boto3-billing","description":"mypy-boto3-billing provides type annotations for the AWS boto3 Billing service. It's part of the `mypy-boto3` project, which generates type stubs for all boto3 services. The library is actively maintained, with frequent updates corresponding to boto3 releases and improvements from the `mypy-boto3-builder`.","status":"active","version":"1.42.26","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["AWS","boto3","mypy","type-hints","billing","cloud"],"install":[{"cmd":"pip install mypy-boto3-billing boto3","lang":"bash","label":"Install with boto3"},{"cmd":"pip install mypy-boto3-billing types-boto3","lang":"bash","label":"Install with types-boto3 (all stubs)"}],"dependencies":[{"reason":"Required for runtime AWS SDK functionality.","package":"boto3","optional":false},{"reason":"Required for static type checking.","package":"mypy","optional":true},{"reason":"Alternative to installing individual service stubs; provides stubs for all services.","package":"types-boto3","optional":true}],"imports":[{"symbol":"BillingClient","correct":"from mypy_boto3_billing.client import BillingClient"},{"symbol":"ListAccountGroupsOutputTypeDef","correct":"from mypy_boto3_billing.type_defs import ListAccountGroupsOutputTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_billing.client import BillingClient\nimport os\n\n# Ensure AWS credentials are set up (e.g., via environment variables or ~/.aws/credentials)\n# For a runnable example, we'll use dummy credentials if not found\nos.environ.setdefault('AWS_ACCESS_KEY_ID', 'test')\nos.environ.setdefault('AWS_SECRET_ACCESS_KEY', 'test')\nos.environ.setdefault('AWS_SESSION_TOKEN', 'test')\nos.environ.setdefault('AWS_DEFAULT_REGION', 'us-east-1')\n\ndef get_billing_summary():\n    client: BillingClient = boto3.client('billing')\n    try:\n        response = client.list_billing_groups(\n            Filters={'And': [{'AttributeValue': 'active', 'AttributeName': 'Status'}]},\n            MaxResults=5\n        )\n        print(\"Successfully retrieved billing groups summary.\")\n        for group in response.get('BillingGroups', []):\n            print(f\"  Billing Group ARN: {group.get('Arn')}, Name: {group.get('Name')}\")\n    except Exception as e:\n        print(f\"Error retrieving billing groups: {e}\")\n\nif __name__ == '__main__':\n    get_billing_summary()\n","lang":"python","description":"This quickstart demonstrates how to initialize a boto3 Billing client with type annotations from `mypy-boto3-billing` and make a simple API call. It correctly hints the `client` variable for static analysis."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher. Ensure your `pyproject.toml` or `setup.py` reflects this change.","message":"Starting with `mypy-boto3-builder` version 8.12.0, Python 3.8 is no longer supported across all generated `mypy-boto3` packages, including `mypy-boto3-billing`. Projects using these stubs must upgrade to Python 3.9 or newer.","severity":"breaking","affected_versions":"mypy-boto3-billing >= 1.42.x (generated by builder 8.12.0+)"},{"fix":"Review your code for any direct references to TypeDef names. Update them according to the new naming conventions if they were affected (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`).","message":"Type Definition (TypeDef) names for service operations were shortened, and the `Extra` postfix for conflicting names was moved in `mypy-boto3-builder` version 8.9.0. While `billing` specific changes might be minimal, this is a general breaking change in the naming convention of generated types.","severity":"breaking","affected_versions":"mypy-boto3-billing >= 1.42.x (generated by builder 8.9.0+)"},{"fix":"Always add a type hint when initializing the boto3 client, e.g., `client: BillingClient = boto3.client('billing')`.","message":"To get full type checking benefits, you must explicitly annotate the boto3 client with the type from `mypy_boto3_billing.client`. Without `client: BillingClient = ...`, mypy will only see the untyped `boto3` client.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Keep `boto3` and `mypy-boto3-billing` versions synchronized as much as possible. It's often best to upgrade both together.","message":"Using an older `boto3` version than what the stubs were generated for can lead to mismatches and type checking errors, as the API might have evolved.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}