Type Annotations for boto3 Invoicing

1.42.3 · active · verified Sat Apr 11

mypy-boto3-invoicing provides comprehensive type annotations for the AWS boto3 Invoicing service. It offers static type checking compatibility for `boto3.client("invoicing")`, `boto3.resource("invoicing")`, and associated response/request `TypeDefs`, enhancing developer experience with auto-completion and early error detection. The library is automatically generated and regularly updated to reflect the latest boto3 versions.

Warnings

Install

Imports

Quickstart

This example demonstrates how to obtain a type-hinted Invoicing client and use a specific `TypeDef` for its response. Note that 'invoicing' is generally not a publicly exposed boto3 service, and this example primarily serves to illustrate the type-hinting mechanism for a typical `mypy-boto3` service. For actual AWS services, replace `invoicing` with an available service like `s3` or `ec2`.

import boto3
from mypy_boto3_invoicing.client import InvoicingClient
from mypy_boto3_invoicing.type_defs import GetInvoicesOutputTypeDef

def get_invoices(invoice_id: str) -> GetInvoicesOutputTypeDef:
    # Using type annotation for the client enables auto-completion and type checking
    client: InvoicingClient = boto3.client("invoicing")
    response: GetInvoicesOutputTypeDef = client.get_invoices(InvoiceId=invoice_id)
    print(f"Invoice Status: {response.get('Status')}")
    return response

# Example usage (replace with actual invoice ID if running)
if __name__ == "__main__":
    # Invoicing is not a public AWS service, this is a placeholder example.
    # Replace with actual Invoicing API calls if available or adapt for other boto3 services.
    try:
        # This call will likely fail for a non-existent/public 'invoicing' service.
        # The purpose here is to demonstrate type hinting.
        result = get_invoices(invoice_id="invoice-123")
    except Exception as e:
        print(f"Caught expected exception for example: {e}")

view raw JSON →