{"id":3106,"library":"mypy-boto3-kafka","title":"Type annotations for boto3 Kafka","description":"mypy-boto3-kafka provides type annotations for the AWS boto3 Kafka service. It is a generated library, currently at version 1.42.65, built with mypy-boto3-builder 8.12.0. Its release cadence generally follows updates to the underlying boto3 library and the builder.","status":"active","version":"1.42.65","language":"python","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["type-stubs","boto3","aws","kafka","mypy","typing","aws-msk"],"install":[{"cmd":"pip install mypy-boto3-kafka","lang":"bash","label":"Install specific Kafka service stubs"},{"cmd":"pip install boto3-stubs[kafka]","lang":"bash","label":"Install Kafka stubs as part of boto3-stubs extras"}],"dependencies":[{"reason":"Provides the runtime functionality for which these are type stubs.","package":"boto3","optional":false}],"imports":[{"wrong":"from mypy_boto3_kafka import KafkaClient","symbol":"KafkaClient","correct":"from mypy_boto3_kafka import KafkaClient"}],"quickstart":{"code":"import os\nimport boto3\nfrom mypy_boto3_kafka import KafkaClient\n\n# Ensure boto3 is configured, e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION_NAME env vars\n\nregion = os.environ.get('AWS_REGION_NAME', 'us-east-1')\n\ndef get_kafka_client() -> KafkaClient:\n    session = boto3.Session(region_name=region)\n    client: KafkaClient = session.client('kafka')\n    return client\n\nkafka_client = get_kafka_client()\nresponse = kafka_client.list_clusters_v2()\n\nprint(f\"Kafka Clusters: {response.get('ClusterInfoList')}\")","lang":"python","description":"Demonstrates how to import and use the KafkaClient type stub with a standard boto3 session to get type-hinted AWS MSK operations."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher. The library specifies `requires_python: >=3.9`.","message":"The underlying mypy-boto3-builder (version 8.12.0) has removed support for Python 3.8. Therefore, mypy-boto3-kafka no longer supports Python 3.8.","severity":"breaking","affected_versions":"mypy-boto3-kafka >= 1.42.65 (built with mypy-boto3-builder 8.12.0)"},{"fix":"Review explicit `TypeDef` imports and usage, updating names according to the new conventions if affected. Most users relying on IDE auto-completion for these should adapt automatically.","message":"mypy-boto3-builder version 8.9.0 introduced breaking changes to `TypeDef` naming conventions. Type definitions for packed method arguments use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`), and conflicting `Extra` postfixes were moved (e.g., `CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`).","severity":"breaking","affected_versions":"mypy-boto3-kafka versions built with mypy-boto3-builder >= 8.9.0"},{"fix":"Ensure `boto3` is installed alongside `mypy-boto3-kafka` (e.g., `pip install boto3 mypy-boto3-kafka`).","message":"This package provides only type stubs. For actual runtime functionality, you must also install and configure the `boto3` library.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For `mypy-boto3-kafka`, consider using the `types-boto3-lite[kafka]` package or disabling PyCharm's type checker and relying on an external tool like `mypy` or `pyright`.","message":"When using PyCharm, performance issues with `Literal` overloads might occur. It's recommended to disable PyCharm's internal type checker or use `boto3-stubs-lite` variants for better performance.","severity":"gotcha","affected_versions":"All versions (PyCharm specific)"},{"fix":"Use a pattern like:\n```python\nfrom typing import TYPE_CHECKING\nif TYPE_CHECKING:\n    from mypy_boto3_kafka import KafkaClient\nelse:\n    KafkaClient = object\n\n# Use KafkaClient\n```","message":"For Pylint compatibility and to avoid runtime dependencies on type stubs, it is common to guard imports with `if TYPE_CHECKING:` and set types to `object` in the `else` branch. Pylint might otherwise complain about undefined variables.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'1.42.65':27 '8.12.0':34 'annot':2,12 'aw':15,53,58 'aws-msk':57 'boto3':4,8,16,32,44,52 'builder':33,48 'built':28 'cadenc':37 'current':24 'follow':39 'general':38 'generat':22 'kafka':5,9,17,54 'librari':23,45 'msk':59 'mypi':7,31,55 'mypy-boto3-builder':30 'mypy-boto3-kafka':6 'provid':10 'releas':36 'servic':18 'stub':51 'type':1,11,50,56 'type-stub':49 'under':43 'updat':40 'version':26","created_at":"2026-04-11T09:21:18.919007+00:00","updated_at":"2026-04-16T17:00:34.119258+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/tmp/tmpg6k0n9_7/venv/lib/python3.12/site-packages/mypy_boto3_kafka/__init__.py\", line 51, in <module>\n    from .client import KafkaClient\n  File \"/tmp/tmpg6k0n9_7/venv/lib/python3.12/site-packages/mypy_boto3_kafka/cli"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.43.79","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/youtype/mypy_boto3_builder","docs":"https://youtype.github.io/boto3_stubs_docs/mypy_boto3_kafka/","changelog":null,"pypi":"https://pypi.org/project/mypy-boto3-kafka/","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-28","next_check":"2026-07-10","install_tag":null}}