{"id":3336,"library":"mypy-boto3-b2bi","title":"Type Annotations for Boto3 B2BI","description":"mypy-boto3-b2bi provides comprehensive type annotations for the AWS B2BI service client in `boto3`. It's part of the `mypy-boto3` collection, which generates type stubs for all `boto3` services, enhancing developer experience with static analysis and auto-completion. The current version is 1.42.3, and new versions are released frequently, typically mirroring `boto3` updates and `mypy-boto3-builder` releases.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","aws","types","mypy","type-hinting","b2bi"],"install":[{"cmd":"pip install boto3 mypy-boto3-b2bi","lang":"bash","label":"Install Boto3 and B2BI stubs"}],"dependencies":[{"reason":"Provides the underlying AWS SDK client that these type stubs annotate. `boto3` must be installed and kept updated to match the stub versions for accurate type checking.","package":"boto3","optional":true}],"imports":[{"note":"The type stubs are provided by `mypy_boto3_b2bi`, not directly by `boto3`'s runtime components. Explicitly importing the `B2BIClient` type from the stub package enables static type checking.","wrong":"from boto3.client import B2BIClient","symbol":"B2BIClient","correct":"from mypy_boto3_b2bi.client import B2BIClient"},{"note":"Accessing paginator types for specific operations.","symbol":"paginate","correct":"from mypy_boto3_b2bi.paginator import ListPartnershipsPaginator"},{"note":"Accessing waiter types for specific operations. (Note: B2BI may not have waiters)","symbol":"waiter","correct":"from mypy_boto3_b2bi.waiter import SomeResourceExistsWaiter"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_b2bi import B2BIClient\nfrom typing import Dict, Any\n\n# The actual client comes from boto3. The B2BIClient type from mypy_boto3_b2bi\n# is used to provide type hints for static analysis.\n\ntry:\n    # Assuming AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)\n    client: B2BIClient = boto3.client(\"b2bi\")\n\n    # Example operation: List Partnerships\n    # mypy will now validate the parameters and the structure of the response.\n    response = client.list_partnerships(\n        MaxResults=5 # Optional: limit the number of results\n    )\n\n    partnerships = response.get('partnerships', [])\n    print(f\"Found {len(partnerships)} B2BI partnerships.\")\n    for partnership in partnerships:\n        print(f\" - Partnership ID: {partnership.get('partnershipId')}, Name: {partnership.get('name')}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Ensure 'boto3' and 'mypy-boto3-b2bi' are installed and AWS credentials are configured.\")\n","lang":"python","description":"This quickstart demonstrates how to instantiate a B2BI client from `boto3` and apply the `mypy-boto3-b2bi` type annotations. It performs a simple `list_partnerships` operation, showcasing how static analysis can infer types for client methods and response structures."},"warnings":[{"fix":"Upgrade your project's Python version to 3.9 or newer. Ensure your package manager (e.g., pip) is up-to-date to correctly handle PEP 561 packages.","message":"The `mypy-boto3-builder` (version 8.12.0, which generated mypy-boto3-b2bi 1.42.3) removed support for Python 3.8 and migrated to PEP 561 package standards. Projects still on Python 3.8 or relying on older package structures will encounter import or runtime errors.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0 (and generated stubs like mypy-boto3-b2bi >= 1.42.x)"},{"fix":"Always install `boto3` alongside `mypy-boto3-b2bi` using `pip install boto3 mypy-boto3-b2bi`.","message":"`mypy-boto3-b2bi` provides only type stubs. For the code to run, the actual `boto3` library must be installed. The stubs themselves do not include the AWS SDK functionality.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Aim to keep `boto3` and `mypy-boto3-b2bi` versions as closely aligned as possible. Ideally, update them simultaneously or choose `mypy-boto3-b2bi` versions that explicitly state compatibility with your `boto3` version.","message":"Significant version mismatches between `boto3` and `mypy-boto3-b2bi` can lead to incorrect or missing type hints, as the stubs are generated to match specific `boto3` service definitions.","severity":"gotcha","affected_versions":"All versions"},{"fix":"After updating, review any code that directly references generated TypeDef classes (e.g., for custom validation or mock objects) and adjust to the new naming conventions.","message":"The `mypy-boto3-builder` (from version 8.9.0) introduced changes to generated TypeDef naming conventions (e.g., shorter names, altered postfix placement). While specific examples may not be for B2BI, direct reliance on exact TypeDef names from previous versions may break after an upgrade.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.9.0 and subsequently generated stubs."},{"fix":"Consult `mypy-boto3-builder` release notes and AWS documentation when upgrading or if type errors appear unexpectedly for specific services.","message":"Specific AWS services may be renamed or deprecated, leading to their corresponding `mypy-boto3-*` stub packages being updated or removed (e.g., `sms-voice` replaced by `pinpoint-sms-voice` in builder v8.11.0). While not directly impacting B2BI currently, this indicates a general risk for other services.","severity":"deprecated","affected_versions":"All versions, depending on AWS service updates."}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}